-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Support matching JSON body with CEL expressions #1255
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
Support matching JSON body with CEL expressions #1255
Conversation
45e8b9c
to
2f2d0fb
Compare
@roidelapluie @mem Ping :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of minor comments.
Thank you for this, this seems useful! Question, I have no experience with CEL... is it possible to use it to match HTML, too? I see in the code that Eval takes a The reason I'm asking is because I'm trying to figure out if it's possible to extend this to more inputs, or if it needs to be restricted to JSON. |
0c9b9a0
to
f9a0036
Compare
I atleast do not know how CEL could be used to match HTML in any sane way. You might want to check this out https://github.com/google/cel-spec/blob/master/doc/langdef.md#json-data-conversion Thanks for your comments and suggestions so far. Really hoping we can get this merged. I think that having the ability to validate JSON responses would be an awesome addition to blackbox exporter. :) |
@mem kindly ping :) we are interested about this feature and would like to see it as well |
f9a0036
to
b9b903b
Compare
fbb6791
to
9131539
Compare
3101080
to
2b1939d
Compare
@mem @roidelapluie any comments to this PR? |
@electron0zero @mem I haven't heard from any of the maintainers in a while. I fixed or clarified everything that was mentioned in the review comments. The initial message I got was that this seems useful, but it seems that it's forgotten now. Any update? I'd love to get this merged in order to avoid maintaining my own fork. :) |
ping @electron0zero @mem could you give some opinion about this? |
a07544b
to
704e04a
Compare
704e04a
to
730f1ac
Compare
@mem I'm willing to donate you a sixpack in exchange for a review at this point. Please either review this or close it if it's not going to make its way into blackbox exporter. |
46b9342
to
d6df03c
Compare
d6df03c
to
41ed81a
Compare
Signed-off-by: Juho Majasaari <juho.majasaari@iki.fi>
Signed-off-by: Juho Majasaari <juho.majasaari@iki.fi>
Signed-off-by: Juho Majasaari <juho.majasaari@iki.fi>
41ed81a
to
e60ce42
Compare
e60ce42
to
8bb2ecb
Compare
Signed-off-by: Juho Majasaari <juho.majasaari@iki.fi>
Signed-off-by: Juho Majasaari <juho.majasaari@iki.fi>
Signed-off-by: Juho Majasaari <juho.majasaari@iki.fi>
Signed-off-by: Juho Majasaari <juho.majasaari@iki.fi>
Signed-off-by: Juho Majasaari <juho.majasaari@iki.fi>
8bb2ecb
to
ce74f98
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started reviewing if JSON types other than objects would work, in the end I wrote some tests and made them work.
(This will probably need gofmt before committing, I should just have pushed a commit...)
Co-authored-by: David Leadbeater <dgl@dgl.cx> Signed-off-by: Juho Majasaari <juho.majasaari@iki.fi>
6f0ca3a
to
edca4bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, after comment resolved. Thanks! I'll leave final review to a maintainer though.
Signed-off-by: Juho Majasaari <juho.majasaari@iki.fi>
thank you for your contribution , and patience with the review process 🙇 |
This PR implements parsing a JSON response from the body and checking the result using a CEL query. Looking for feedback on this.
Sample usage:
If response is
{"foo": { "bar": "qux" } }
the probe fails. fail_if_body_json_matches_cel is also implemented and should work as expected.