I’m trying to use the Opentelemetry Collector attributeprocessor to write a “hostname” attribute from the journald receiver _HOSTNAME attribute so that the json output will have a field “hostname” in it containing the name/value pair for the hostname.
Other than it not working, the challenge is also getting debug information, enabling debug logging doesn’t show me the processing of my rules. There is no error, if a rule doesn’t match it’s skipped.
The fields I’m trying to process are nested under a body element so what I’ve been trying to do is to change the “from_attribute” to all the possible values I think could be valid body__hostname, body._HOSTNAME, _HOSTNAME for example don’t work.
This is the collector configuration:
receivers:
journald:
processors:
resource:
attributes:
- action: insert
key: loki.format
value: json
- action: insert
key: environment
value: dev
- action: insert
key: loki.resource.labels
value: hostname, priority
attributes:
actions:
- action: insert
key: hostname
from_attribute: _HOSTNAME
- action: insert
key: priority
from_attribute: _PRIORITY
exporters:
loki:
endpoint: xxxx
sending_queue:
num_consumers: 10
queue_size: 50000
headers:
"X-Scope-OrgID": "xxxx"
tls:
ca_file: xxxx
cert_file: xxxx
key_file: xxxx
service:
pipelines:
logs:
receivers: [journald]
processors: [attributes,resource]
exporters: [loki]
And here is my message in Grafana showing the _HOSTNAME field nested under the body element along with all the other fields: