WIP: Initial support for CEL
This adds initial support for queries using the common expression language (CEL).
- [x] Make decision on config format
having additional separate fields
- name: example_cel_global_value
cel: '.baz == "bar" ? 1 : 0'
help: Example of a top-level global value scrape in the json
labels_cel:
environment: '.foo'
vs. defining an engine for the query
- name: example_cel_global_value
path: '.baz == "bar" ? 1 : 0'
help: Example of a top-level global value scrape in the json
engine: cel # default is jsonpath
labels:
environment: '.foo'
- [x] Add support for labels, values and epochTimestamp
- [ ] Add documentation
See: https://github.com/prometheus-community/json_exporter/issues/263
@superq @rustycl0ck any thoughts on this? Would love to get some early feedback to see if this is something you'd be interested in adding.
Thanks a lot for this MR, just tested this branch and it seems to work fine. We used:
- name: example_cel_global_value
cel: '.state == "printing" ? 1 : 0'
help: Example of a top-level global value scrape in the json
labels:
environment: beta # static label
This should potentially solve a lot of related issues that need a bit more advance logic, such as: https://github.com/prometheus-community/json_exporter/issues/151
Please add a bit of documentation, then it would be perfect 🚀
@sbor23 thanks for testing it! I still need to figure out a couple of things here, I have updated the original messages
I went ahead with the engine field solution
- name: example_cel_global_value
engine: cel
path: '.counter'
help: Example of a top-level global value scrape in the json using cel
valuetype: 'gauge'
labels:
environment: "\"beta\"" # static label. Quotes need to be escaped for CEL
location: "\"planet-\"+.location" # dynamic label. Quotes need to be escaped for CEL