mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-26 08:05:53 +03:00
[GH-ISSUE #854] LogstashFormatter and numeric contextPrefix keys #336
Labels
No labels
Bug
Documentation
Feature
Needs Work
Support
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/monolog#336
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @KIVagant on GitHub (Sep 20, 2016).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/854
The LogstashFormatter have a problem in this file:
manage_template => truein the elasticsearch output section.$record['context']has a numeric keys and different types of values.Than fields with the names 'ctxt_0', 'ctxt_1' etc will be created automatically in the ElasticSearch index.
And if formatter will called twice with a different $context array, for example
[0, 1]and['aaa','bbb']then Logstash will throw an error:Because field was created with a type 'number' at the first time.
I have no idea how to fix that with a correct way. Maybe instead of using numeric keys suffixes the sub-array must be created with the key 'ctxt_something'? For example:
Up: I have checked, this wasn't help.
So now I have only this working variant:
@Seldaek commented on GitHub (Sep 25, 2016):
It seems like the issue really is that you sometimes pass numbers and sometimes strings into a given context key..
The best option IMO is to make sure you always name your context, so always pass something like
['count' => 0]or['foo' => 'bar'], that way you won't twice end up with ctxt_0, but rather ctxt_count (int type) and ctxt_foo (string type)..In any case, I don't think it's something we can do on monolog's end I'm afraid.