Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Grammar update: lock expression #136

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

jkassemi
Copy link

Hey folks, not sure if there's any interest, but figured I'd pass this along. Adds the ability to limit an expression by appending a filter expression to the end of a metric or event expression.

This allows us to create an interface to the Cube evaluator and still allow the client to provide the initial expression. Our application just needs to append the lock expression before forwarding to our (well secured) evaluator.

Feedback's awesome, this is one of my very few forays into node.

Adds a lock expression to the grammar for event expressions
and metric expressions - a string that can be appended automatically
to an expression prior to parsing that limits the results the
expression has access to.

This doesn't let us open the Cube server to the public directly, but
it does allow us to rewrite the expression in requests through an
intermediate service to help prohibit access:

  expression= sum(nginx_requests.size):nginx_requests.eq(user, 'rocky')

limits the sum to the nginx_requests with a 'user' attribute of 'rocky,'
assuming, you store that parameter in nginx_requests, of course. So, we can
allow the client to send an expression, tack on the lock expression with our
web app after authenticating the user, and then forward the request to
cube and send back the response to the client while limiting access to the
underlying records.

Utilizes the core filter parsing already in place.
… from some play-around code I mistakenly pushed up)
@Marsup
Copy link

Marsup commented Oct 17, 2013

That seems like a nice addition, but that wouldn't work very well with multiple operations. I like the idea but I'm not sure it's the best way to express constraints, though I have nothing better to offer yet :)

@jkassemi
Copy link
Author

I considered adding additional parameters to the request - so the event and metric getters would then filter based on those parameters. This turned out much cleaner - got some samples of multiple operations that you use that could get my head working through some possibilities?

@Marsup
Copy link

Marsup commented Oct 21, 2013

A meaningless example would be sum(test.gt(i, 42)) + min(test2.lt(i, 24)) but you get the idea.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants