I am currently getting logs through Loki log driver and they are shown in a Grafana dashboard.
I am trying to remove (or replace with “”) a part of a value based on another label’s value.
For example the following labels: swarm_service=application_dev_api and swarm_stack=application_dev and I only need the part of swarm_service where the value of swarm_stack is removed, so basically the new label, let’ call it service-shortened, will have the value _api.
I could maybe try to regex match it with _ (underscore) as separator, but with the example above it wouldn’t work because swarm_stack already has an underscore in its value.
Is there another way to achieve this?
I don’t think it’s possible to change a label’s value using another label as variable.
Can you give an example log and what you are trying to achieve?