Hi,

First thanks for the cool module :)

I had following problem with Elastic:
When I send the logged json to Elastic it creates new fields for each variable in variables property/array from $entry object (which are a lot) and also the message is with place holders.

Currently I handled this with adding an alter just before writing in the file (see attached image). That way I replaced the placeholders in the message with the info from variables property and unset variables property.

Can you suggest something better or add this alter option to the module?

BR,
Metodiy

Comments

jacobfriis’s picture

Assigned: mkozhuharov » jacobfriis

@mkozhuharov
Thx for your info and suggestion.
Replacement of variables in the message should rather be performed on demand by the log client.
Because replacement introduces an extra overhead. And that overhead is mostly redundant, because in the practical world nobody reads every single log entry.
But I'll check with the Elasticsearch guys at my workplace how they handle variables.
And an option for JSONlog to do the replacement sounds like a good idea.

jacobfriis’s picture

Assigned: jacobfriis » Unassigned
Status: Active » Needs review
StatusFileSize
new1.78 KB

@mkozhuharov
I believe you're right ;-) It doesn't make practical sense that ElasticSearch should replace variables into messages.
However, I'm not fond of drupal_alter'ing because of the overhead involved in hook invokation.
So with ...-2.patch JSONlog now does the job. And the feature is not a conf option, but mandatory - the module has enough options as it is.

The replacement is performed exactly the same way as format_string() does it - except JSONlog doesn't wrap replacements in placeholder HTML tags (because HTML is not really desirable in this context).

jacobfriis’s picture

This patch is not compatible with: #2427723...-4.
Combined patch: jsonlog-combine-issues-2427723-and-2448753.patch

mkozhuharov’s picture

@jacobfriis
Thanks for the patch :)

jacobfriis’s picture

StatusFileSize
new9.84 KB

Oops, variable replacement should take place _before_ escaping.

jacobfriis’s picture

Status: Needs review » Closed (fixed)

Fixed in JSONlog 7.x-2.1.