Skip to content

Commit

Permalink
query: add --endpoint-strict flag to statically configure endpoints (
Browse files Browse the repository at this point in the history
…#4874)

* add `--endpoint-strict` flag to add statically configured endpoints

Signed-off-by: Hitanshu Mehta <hitanshu99amehta@gmail.com>

* make docs

Signed-off-by: Hitanshu Mehta <hitanshu99amehta@gmail.com>

* Add CHANGELOG entry and fix nit

Signed-off-by: Hitanshu Mehta <hitanshu99amehta@gmail.com>
  • Loading branch information
hitanshu-mehta committed Nov 16, 2021
1 parent a169d12 commit 16a8bc3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
- [#4612](https://github.com/thanos-io/thanos/pull/4612) Sidecar: add `--prometheus.http-client` and `--prometheus.http-client-file` flag for sidecar to connect Prometheus with basic auth or TLS.
- [#4847](https://github.com/thanos-io/thanos/pull/4847) Query: add `--alert.query-url` which is used in the user interface for rules/alerts pages. By default the HTTP listen address is used for this URL.
- [#4856](https://github.com/thanos-io/thanos/pull/4856) Mixin: Add Query Frontend Grafana dashboard.
- [#4874](https://github.com/thanos-io/thanos/pull/4874) Query: Add `--endpoint-strict` flag to statically configure Thanos API server endpoints. It is similar to `--store-strict` but supports passing any Thanos gRPC APIs: StoreAPI, MetadataAPI, RulesAPI, TargetsAPI and ExemplarsAPI.

### Fixed

Expand Down
17 changes: 16 additions & 1 deletion cmd/thanos/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,12 @@ func registerQuery(app *extkingpin.App) {
targetEndpoints := cmd.Flag("target", "Deprecation Warning - This flag is deprecated and replaced with `endpoint`. Experimental: Addresses of statically configured target API servers (repeatable). The scheme may be prefixed with 'dns+' or 'dnssrv+' to detect target API servers through respective DNS lookups.").
Hidden().PlaceHolder("<target>").Strings()

strictStores := cmd.Flag("store-strict", "Addresses of only statically configured store API servers that are always used, even if the health check fails. Useful if you have a caching layer on top.").
strictStores := cmd.Flag("store-strict", "Deprecation Warning - This flag is deprecated and replaced with `endpoint-strict`. Addresses of only statically configured store API servers that are always used, even if the health check fails. Useful if you have a caching layer on top.").
PlaceHolder("<staticstore>").Strings()

strictEndpoints := cmd.Flag("endpoint-strict", "Addresses of only statically configured Thanos API servers that are always used, even if the health check fails. Useful if you have a caching layer on top.").
PlaceHolder("<staticendpoint>").Strings()

fileSDFiles := cmd.Flag("store.sd-files", "Path to files that contain addresses of store API servers. The path can be a glob pattern (repeatable).").
PlaceHolder("<path>").Strings()

Expand Down Expand Up @@ -288,6 +291,7 @@ func registerQuery(app *extkingpin.App) {
time.Duration(*instantDefaultMaxSourceResolution),
*defaultMetadataTimeRange,
*strictStores,
*strictEndpoints,
*webDisableCORS,
enableAtModifier,
enableNegativeOffset,
Expand Down Expand Up @@ -355,6 +359,7 @@ func runQuery(
instantDefaultMaxSourceResolution time.Duration,
defaultMetadataTimeRange time.Duration,
strictStores []string,
strictEndpoints []string,
disableCORS bool,
enableAtModifier bool,
enableNegativeOffset bool,
Expand Down Expand Up @@ -392,6 +397,12 @@ func runQuery(
}
}

for _, endpoint := range strictEndpoints {
if dns.IsDynamicNode(endpoint) {
return errors.Errorf("%s is a dynamically specified endpoint i.e. it uses SD and that is not permitted under strict mode. Use --endpoint for this", endpoint)
}
}

dnsEndpointProvider := dns.NewProvider(
logger,
extprom.WrapRegistererWithPrefix("thanos_query_endpoints_", reg),
Expand Down Expand Up @@ -432,6 +443,10 @@ func runQuery(
specs = append(specs, query.NewGRPCEndpointSpec(addr, true))
}

for _, addr := range strictEndpoints {
specs = append(specs, query.NewGRPCEndpointSpec(addr, true))
}

for _, dnsProvider := range []*dns.Provider{
dnsStoreProvider,
dnsRuleProvider,
Expand Down
15 changes: 11 additions & 4 deletions docs/components/query.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ Flags:
prefixed with 'dns+' or 'dnssrv+' to detect
Thanos API servers through respective DNS
lookups.
--endpoint-strict=<staticendpoint> ...
Addresses of only statically configured Thanos
API servers that are always used, even if the
health check fails. Useful if you have a
caching layer on top.
--grpc-address="0.0.0.0:10901"
Listen ip:port address for gRPC endpoints
(StoreAPI). Make sure this address is routable
Expand Down Expand Up @@ -382,10 +387,12 @@ Flags:
'dns+' or 'dnssrv+' to detect store API servers
through respective DNS lookups.
--store-strict=<staticstore> ...
Addresses of only statically configured store
API servers that are always used, even if the
health check fails. Useful if you have a
caching layer on top.
Deprecation Warning - This flag is deprecated
and replaced with `endpoint-strict`. Addresses
of only statically configured store API servers
that are always used, even if the health check
fails. Useful if you have a caching layer on
top.
--store.response-timeout=0ms
If a Store doesn't send any data in this
specified duration then a Store will be ignored
Expand Down

0 comments on commit 16a8bc3

Please sign in to comment.