Skip to content

Using a field value as a field name #8746

Answered by jszwedko
AdAndre asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @AdAndre !

It does appear like this isn't quite possible yet. I thought something like:

$ . = {"gauge":{"value":973.0},"kind":"absolute","name":"scrape_samples_scraped","tags":{"job":"node_exporter"}}
{ "gauge": { "value": 973 }, "kind": "absolute", "name": "scrape_samples_scraped", "tags": { "job": "node_exporter" } }

$ { "fields": merge(foo.tags, { "metric_name:" + .name: .value }) }

error[E203]: syntax error
  ┌─ :1:53
  │
1 │ { "fields": merge(foo.tags, { "metric_name:" + .name: .value }) }

Might work, but it didn't. I think this is related partially related to #7050 , but a bit different. I'll convert this discussion into an issue for tracking.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@AdAndre
Comment options

Answer selected by jszwedko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants