-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not able to copy/move from sub object to attributes (merge) #35020
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
This limitation was a design decision made long ago when some guidelines were created to govern whether to allow e.g. copying to That said, I think what you're asking for is quite reasonable and we could reconsider the cited guideline: It's not clear to me at this point that allowing validity to be determined dynamically is really a problem here. It's not all that different from trying to copy from an attribute that turns out not to be present. I think the broader implications of this change look something like this:
If I recall correctly, the implementation could be a bit tricky but there is at least one other operator which introduced a notion of referring to |
That's cool to hear! Thanks for the quick reply. I was wondering if what I'm doing was completely beyond the guardrails here. So I guess the fact that I'm parsing OTLP/JSON format logs from stdout output is mostly unsupported? Wouldn't this be a more scalable way to process logs from my application stack in general? Moreover, as you mentioned allowing I'm basically ingesting logs from a full cluster, where some apps output unstructured stdio logs, and some output OTLP JSON (with some doing both). Right now I've routed the OTLP formatted logs back over HTTP to our collector, but I'd prefer that they all end up on stdout for the aforementioned scaling reason. |
This next item I'm having, along the same vein, is probably related to #35049: I'm not able to manually set severity:
The severity parser isn't working for me (not related to this issue), but I could have overcome that limitation had I been able to manually set these properties as above. Of course I get similar errors:
|
I didn't catch that was your goal. Have you looked at using the |
You should be able to use the severity parser to set severity number, but the text is intentionally preserved. You could do something like though: operators:
- type: add
field: attributes["log.iostream"]
value: ERROR
if: attributes["log.iostream"] == "stderr"
- type: add
field: attributes["log.iostream"]
value: INFO
if: attributes["log.iostream"] == "stdout"
severity_parser:
parse_from: attributes["log.iostream"] |
Seems I forgot about a feature we added which may do just what you're looking for wrt severity text: #26671 |
Thanks, that severity overwrite_text option did the trick.
Well, not quite.. I have a bunch of services running in a k8s cluster. Most of them I control, some I do not. The ones I do not are going to output some random log format to stdout.. that's cool, I can't control that but I still want to process their logs - hence filelog receiver. The ones I do control, I want to monitor but with added granularity. I want to log in OTLP format - specifically JSON, so that all of the attributes and resource labels I'm adding are retained. Of course due to scaling etc. I would also want the logs in the OTLP format going to the same location as all the other logs I'm already collecting - stdout / stderr. The problem here is not getting them into the same stream - I can use the console log exporter in NodeJS for that - but rather once they're in the stdout stream, how can I properly process them using I can't move any sub object to root, which would be easiest. Failing that I'd expect to be able to move a sub object directly to Ultimately having an operator like |
You should look at the new
It sounds like The ideal solution would be to use the routing connector to separate the logs, into separate processing pipelines. Then you could run only the otlpjson formatted logs through the The challenge is that the routing connector currently only supports routing based on resource attributes. To address this, you could annotate a resource attribute onto the appropriate logs. Your config might look something like this: receivers:
filelog:
include: ...
operators:
- type: container
- type: add
field: resource["log.type"]
value: otlpjson
if: ... # TODO figure out how to detect otlp json format consistently
connectors:
routing:
default_pipelines: [logs/nonotlp]
table:
- statement: route() where attributes["log.type"] == "otlpjson"
pipelines: [logs/rehydrate]
otlpjson:
exporters:
foo: ...
service:
pipelines:
logs/in:
receivers: [ filelog ]
exporters: [ routing ]
logs/rehydrate:
receivers: [ routing ]
exporters: [ otlpjson ]
logs/rehydrated:
receivers: [ otlpjson ]
exporters: [ foo ]
logs/nonotlpjson:
receivers: [ routing ]
exporters: [ foo ] |
Ah that's really interesting! Looks quite advanced. Though I'm still a bit confused about how I go from potentially a parsed sub-property or JSON object on the {
"body": {
"body": "test log",
"trace_id": "..."
},
"resource": {},
"attributes": {}
} |
The |
This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
Component(s)
pkg/stanza, receiver/filelog
What happened?
Description
I'm receiving a blob of JSON, occasionally, on
attributes.log
, in afilelog
receiver. If and when this field is present, I'm parsing it and setting it to another attribute fieldattributes.otlp
. These logs are generally a single line of Open Telemetry formatted JSON that need merging with the current log item.After parsing successfully to the
attributes.otlp
property, I'm trying to move and merge sub properties of that field to theattributes
top level object. I receive an error when trying to do so.Here's the log format before I add the copy/move operator:
Steps to Reproduce
Please pardon the formatting, I'm configuring the receiver and collector using Terraform. Below is a snippet of the operators I'm using, which cause the issue:
Adding the last
copy
operator (same issue formove
) breaks the process, with the following error:To re-cap, the first two operators result in the uppermost example of the log object. Adding the final
copy
operator results in the error.Expected Result
I'd expect that the
attributes.otlp.attributes
object, when present, be merged into the top-levelattributes
. Either that, or have the filelog receiver provide a way to merge a JSON parsed object over the entire log object at the root.Actual Result
An error as shown above.
Collector version
0.101.1
Environment information
Environment
OS: Docker - Helm chart on Kubernetes
OpenTelemetry Collector configuration
(entire configuration not applicable)
Log output
Additional context
No response
The text was updated successfully, but these errors were encountered: