Skip to content
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

WIP: Initial support for CEL #267

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mrueg
Copy link
Member

@mrueg mrueg commented Oct 30, 2023

This adds initial support for queries using the common expression language (CEL).

  • 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'
  • Add support for labels, values and epochTimestamp
  • Add documentation

See: #263

@mrueg
Copy link
Member Author

mrueg commented Oct 31, 2023

@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.

@sbor23
Copy link

sbor23 commented Nov 7, 2023

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:
#151

Please add a bit of documentation, then it would be perfect 🚀

@mrueg
Copy link
Member Author

mrueg commented Nov 7, 2023

@sbor23 thanks for testing it! I still need to figure out a couple of things here, I have updated the original messages

@mrueg mrueg force-pushed the add-cel branch 2 times, most recently from 75a0c7e to 72ab3d8 Compare November 16, 2023 14:07
@mrueg
Copy link
Member Author

mrueg commented Nov 16, 2023

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

@mrueg mrueg force-pushed the add-cel branch 2 times, most recently from 5a26a4a to bdc4eb9 Compare November 16, 2023 21:46
@mrueg mrueg force-pushed the add-cel branch 2 times, most recently from d0c9753 to 5f61823 Compare March 27, 2024 19:49
This adds initial support for queries using the common expression
language (CEL).

ValueToJSON function is adapted from
https://github.com/google/cel-go/blob/cfbf821f1b458533051306305a39b743db7c4bdb/codelab/codelab.go#L274
(Apache-2.0 Licensed)

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants