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

Allow specifying multiple filtersets. #113

Merged
merged 1 commit into from
Apr 15, 2019
Merged

Allow specifying multiple filtersets. #113

merged 1 commit into from
Apr 15, 2019

Conversation

knyar
Copy link
Contributor

@knyar knyar commented Apr 4, 2019

This allows specifying multiple sets of filters that time series will be
checked against. It also switches to using promql native parser for
filters.

Existing --filter flag will keep working, but is now marked as
deprecated.

This makes #106 obsolete.

@StevenYCChou
Copy link
Contributor

Thanks for contributing, @knyar! As this PR is large, we will take some time to review it. I will try to make this PR get reviewed within 1 day.

@StevenYCChou StevenYCChou self-requested a review April 5, 2019 15:10
README.md Outdated Show resolved Hide resolved
cmd/stackdriver-prometheus-sidecar/main.go Show resolved Hide resolved
@StevenYCChou
Copy link
Contributor

@fabxc I saw you implemented filter. I am interested what the motivation you only choose validating against regexp and labels.Matcher?

cmd/stackdriver-prometheus-sidecar/main.go Outdated Show resolved Hide resolved
cmd/stackdriver-prometheus-sidecar/main_test.go Outdated Show resolved Hide resolved
cmd/stackdriver-prometheus-sidecar/main.go Show resolved Hide resolved
cmd/stackdriver-prometheus-sidecar/main_test.go Outdated Show resolved Hide resolved
retrieval/series_cache.go Outdated Show resolved Hide resolved
retrieval/series_cache_test.go Outdated Show resolved Hide resolved
retrieval/series_cache_test.go Outdated Show resolved Hide resolved
README.md Outdated
@@ -48,14 +48,18 @@ stackdriver-prometheus-sidecar --help

#### Filters

The `--filter` flag allows to provide filters which all series have to pass before being sent to Stackdriver. The flag may be repeated to provide several filters. Filters use the same syntax as the well-known PromQL label matchers, e.g.:
The `--filterset` flag allows to provide filters which all series have to pass before being sent to Stackdriver. Filters use the same syntax as [Prometheus time series selectors](https://prometheus.io/docs/prometheus/latest/querying/basics/#time-series-selectors), e.g.:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recheck Prometheus document again - we should be really specific on the selector we use.

I think from both design and implementation POV, it's reasonable that we only support "instant vector selectors", not "range vector selectors". "time series selectors" include both of them. The rationale for design is that we should start from minimum set of selectors useful for users - and from what we see, most of the users are using "instant vector selectors" only.

Action item here: change from "time series selectors" to "instant vector selectors", and link to https://prometheus.io/docs/prometheus/latest/querying/basics/#instant-vector-selectors .

Note that your implementation is using ParseMetricSelector, which only works with instant vector selector.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed, though I think 'time series selectors' would be more clear to someone who is not intimately familiar with Prometheus data model.

@@ -231,7 +232,10 @@ func main() {
a.Flag("web.listen-address", "Address to listen on for UI, API, and telemetry.").
Default("0.0.0.0:9091").StringVar(&cfg.listenAddress)

a.Flag("filter", "PromQL-style label matcher which must pass for a series to be forwarded to Stackdriver. May be repeated.").
a.Flag("filterset", "PromQL metric and label matcher which must pass for a series to be forwarded to Stackdriver. If repeated, the series must pass any filter set to be forwarded.").
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I felt that filterset does not serve well for the value we accept - as the value of filterset is not just comma split string (which fits the name filterset more), but instant vector selector from PromQL.

Also filterset and filter are really similar, which may confuse our users. Can you find an alternative name here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that filterset is not a great name, though being related to filter makes it clear that both flags are controlling the same thing.

Do you like --whitelist or --metric better?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for coming up with the name. Whitelist sounds good for me.

@knyar
Copy link
Contributor Author

knyar commented Apr 10, 2019

Added another commit addressing comments; will squash commits later when you're happy with the changes.

Copy link
Contributor

@StevenYCChou StevenYCChou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for accomodating the feedback and provide your thoughts! The PR looks good so far, and I think the only thing left is the parameter naming for metric whitelist/filtering.

@knyar
Copy link
Contributor Author

knyar commented Apr 12, 2019

Renamed --filterset to --whitelist, PTAL.

@StevenYCChou
Copy link
Contributor

Javier and I have chatted over the naming. He mentioned that whitelist may not be a good term. I looked up whitelist in English dictionaries:

  • "a list of people or things that are considered by a particular authority or group to be acceptable and that should be trusted" from Cambridge Dictionary
  • "A list of people or things considered to be acceptable or trustworthy" from Oxford Dictionary

As in both dictionaries, they are all defined related to authority/trustworthy, I agreed that whitelist is not a good term here, as we are considering "what user want to send" to Stackdriver API, not considering authority/trustworthy.

What do you think about using --include as user-facing parameter, and still use filterset as the variable inside the code, as include may not be a good name for variable inside the code?

@knyar
Copy link
Contributor Author

knyar commented Apr 15, 2019

What do you think about using --include as user-facing parameter, and still use filterset as the variable inside the code, as include may not be a good name for variable inside the code?

Sounds good, I've renamed the variables back to filterset, and the flag is now called --include.

Copy link
Contributor

@StevenYCChou StevenYCChou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, only one minor change for logging message before merging back.

Note: can you create new commit on top of existing commits instead of force pushing? In this way, code reviewer has option to do incremental code review by reviewing commit one by one.

cmd/stackdriver-prometheus-sidecar/main.go Outdated Show resolved Hide resolved
This allows specifying multiple sets of filters that time series will be
checked against. It also switches to using promql native parser for
filters.

Existing `--filter` flag will keep working, but is now marked as
deprecated.
@StevenYCChou StevenYCChou merged commit 6de434d into Stackdriver:master Apr 15, 2019
@StevenYCChou
Copy link
Contributor

Thanks for contributing, @knyar ! I just merged this PR after reviewing your latest change on log message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants