From 8e9b8d499d6a2099229441c7ba3f43b0704f4c31 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 29 Nov 2021 10:33:47 -0500 Subject: [PATCH 1/8] feat: render IPv6 links (#9853) * feat: render IPv6 links Signed-off-by: mtfoley --- .../src/pages/targets/EndpointLink.test.tsx | 25 ++++++++++++++----- .../src/pages/targets/EndpointLink.tsx | 23 ++++++++++------- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/web/ui/react-app/src/pages/targets/EndpointLink.test.tsx b/web/ui/react-app/src/pages/targets/EndpointLink.test.tsx index 6ec6829425..9133219f69 100644 --- a/web/ui/react-app/src/pages/targets/EndpointLink.test.tsx +++ b/web/ui/react-app/src/pages/targets/EndpointLink.test.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { shallow, mount } from 'enzyme'; -import { Badge, Alert } from 'reactstrap'; +import { Badge } from 'reactstrap'; import EndpointLink from './EndpointLink'; describe('EndpointLink', () => { @@ -29,11 +29,24 @@ describe('EndpointLink', () => { const targetLabel = badges.filterWhere((badge) => badge.children().text() === 'target="http://some-service"'); expect(targetLabel.length).toEqual(1); }); - - it('renders an alert if url is invalid', () => { - const endpointLink = shallow(); - const err = endpointLink.find(Alert); - expect(err.render().text()).toEqual('Error: Invalid URL: afdsacas'); + // In cases of IPv6 addresses with a Zone ID, URL may not be parseable. + // See https://github.com/prometheus/prometheus/issues/9760 + it('renders an anchor for IPv6 link with zone ID including labels for query params', () => { + const endpoint = + 'http://[fe80::f1ee:adeb:371d:983%eth1]:9100/stats/prometheus?module=http_2xx&target=http://some-service'; + const globalURL = + 'http://[fe80::f1ee:adeb:371d:983%eth1]:9100/stats/prometheus?module=http_2xx&target=http://some-service'; + const endpointLink = shallow(); + const anchor = endpointLink.find('a'); + const badges = endpointLink.find(Badge); + expect(anchor.prop('href')).toEqual(globalURL); + expect(anchor.children().text()).toEqual('http://[fe80::f1ee:adeb:371d:983%eth1]:9100/stats/prometheus'); + expect(endpointLink.find('br')).toHaveLength(1); + expect(badges).toHaveLength(2); + const moduleLabel = badges.filterWhere((badge) => badge.children().text() === 'module="http_2xx"'); + expect(moduleLabel.length).toEqual(1); + const targetLabel = badges.filterWhere((badge) => badge.children().text() === 'target="http://some-service"'); + expect(targetLabel.length).toEqual(1); }); it('handles params with multiple values correctly', () => { diff --git a/web/ui/react-app/src/pages/targets/EndpointLink.tsx b/web/ui/react-app/src/pages/targets/EndpointLink.tsx index 0830172257..504fbc337c 100644 --- a/web/ui/react-app/src/pages/targets/EndpointLink.tsx +++ b/web/ui/react-app/src/pages/targets/EndpointLink.tsx @@ -1,5 +1,5 @@ import React, { FC } from 'react'; -import { Badge, Alert } from 'reactstrap'; +import { Badge } from 'reactstrap'; export interface EndpointLinkProps { endpoint: string; @@ -8,23 +8,28 @@ export interface EndpointLinkProps { const EndpointLink: FC = ({ endpoint, globalUrl }) => { let url: URL; + let search = ''; + let invalidURL = false; try { url = new URL(endpoint); } catch (err: unknown) { - const error = err as Error; - return ( - - Error: {error.message} - - ); + // In cases of IPv6 addresses with a Zone ID, URL may not be parseable. + // See https://github.com/prometheus/prometheus/issues/9760 + // In this case, we attempt to prepare a synthetic URL with the + // same query parameters, for rendering purposes. + invalidURL = true; + if (endpoint.indexOf('?') > -1) { + search = endpoint.substring(endpoint.indexOf('?')); + } + url = new URL('http://0.0.0.0' + search); } const { host, pathname, protocol, searchParams }: URL = url; const params = Array.from(searchParams.entries()); - + const displayLink = invalidURL ? endpoint.replace(search, '') : `${protocol}//${host}${pathname}`; return ( <> - {`${protocol}//${host}${pathname}`} + {displayLink} {params.length > 0 ?
: null} {params.map(([labelName, labelValue]: [string, string]) => { return ( From 56e5946a1ac2f8d40d5c5aa64aa5d057a3567f38 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Nov 2021 01:30:15 +0100 Subject: [PATCH 2/8] build(deps): bump github.com/Azure/azure-sdk-for-go (#9899) Bumps [github.com/Azure/azure-sdk-for-go](https://github.com/Azure/azure-sdk-for-go) from 58.3.0+incompatible to 59.4.0+incompatible. - [Release notes](https://github.com/Azure/azure-sdk-for-go/releases) - [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/Azure/azure-sdk-for-go/compare/v58.3.0...v59.4.0) --- updated-dependencies: - dependency-name: github.com/Azure/azure-sdk-for-go dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6b58e238c1..99a19e4ea3 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/prometheus/prometheus go 1.14 require ( - github.com/Azure/azure-sdk-for-go v58.3.0+incompatible + github.com/Azure/azure-sdk-for-go v59.4.0+incompatible github.com/Azure/go-autorest/autorest v0.11.22 github.com/Azure/go-autorest/autorest/adal v0.9.17 github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect diff --git a/go.sum b/go.sum index 824edb52c3..cc6535c975 100644 --- a/go.sum +++ b/go.sum @@ -51,8 +51,8 @@ collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/Azure/azure-sdk-for-go v16.2.1+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/azure-sdk-for-go v41.3.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= -github.com/Azure/azure-sdk-for-go v58.3.0+incompatible h1:lb9OWePNuJMiibdxg9XvdbiOldR0Yifge37L4LoOxIs= -github.com/Azure/azure-sdk-for-go v58.3.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go v59.4.0+incompatible h1:gDA8odnngdNd3KYHL2NoK1j9vpWBgEnFSjKKLpkC8Aw= +github.com/Azure/azure-sdk-for-go v59.4.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= From 5849521e905f7d27cb2600977ca40598b657e8e2 Mon Sep 17 00:00:00 2001 From: Filip Petkovski Date: Tue, 30 Nov 2021 05:02:07 +0100 Subject: [PATCH 3/8] promtool: Fix credentials file check (#9883) The promtool check config command still uses the bearer_token_file field which is deprecated in favour of authorization.credentials_file. This commit modifies the command to use the new field insted. Fixes #9874 Signed-off-by: fpetkovski --- cmd/promtool/main.go | 6 ++-- cmd/promtool/main_test.go | 30 +++++++++++++++++++ .../authorization_credentials_file.bad.yml | 4 +++ .../authorization_credentials_file.good.yml | 4 +++ 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 cmd/promtool/testdata/authorization_credentials_file.bad.yml create mode 100644 cmd/promtool/testdata/authorization_credentials_file.good.yml diff --git a/cmd/promtool/main.go b/cmd/promtool/main.go index 7ae656c680..e01b95eeb3 100644 --- a/cmd/promtool/main.go +++ b/cmd/promtool/main.go @@ -353,8 +353,10 @@ func checkConfig(agentMode bool, filename string) ([]string, error) { } for _, scfg := range cfg.ScrapeConfigs { - if err := checkFileExists(scfg.HTTPClientConfig.BearerTokenFile); err != nil { - return nil, errors.Wrapf(err, "error checking bearer token file %q", scfg.HTTPClientConfig.BearerTokenFile) + if scfg.HTTPClientConfig.Authorization != nil { + if err := checkFileExists(scfg.HTTPClientConfig.Authorization.CredentialsFile); err != nil { + return nil, errors.Wrapf(err, "error checking authorization credentials or bearer token file %q", scfg.HTTPClientConfig.Authorization.CredentialsFile) + } } if err := checkTLSConfig(scfg.HTTPClientConfig.TLSConfig); err != nil { diff --git a/cmd/promtool/main_test.go b/cmd/promtool/main_test.go index 1a8a470601..59a15b7a7d 100644 --- a/cmd/promtool/main_test.go +++ b/cmd/promtool/main_test.go @@ -203,3 +203,33 @@ func TestCheckTargetConfig(t *testing.T) { }) } } + +func TestAuthorizationConfig(t *testing.T) { + cases := []struct { + name string + file string + err string + }{ + { + name: "authorization_credentials_file.bad", + file: "authorization_credentials_file.bad.yml", + err: "error checking authorization credentials or bearer token file", + }, + { + name: "authorization_credentials_file.good", + file: "authorization_credentials_file.good.yml", + err: "", + }, + } + + for _, test := range cases { + t.Run(test.name, func(t *testing.T) { + _, err := checkConfig(false, "testdata/"+test.file) + if test.err != "" { + require.Contains(t, err.Error(), test.err, "Expected error to contain %q, got %q", test.err, err.Error()) + return + } + require.NoError(t, err) + }) + } +} diff --git a/cmd/promtool/testdata/authorization_credentials_file.bad.yml b/cmd/promtool/testdata/authorization_credentials_file.bad.yml new file mode 100644 index 0000000000..854b8c2293 --- /dev/null +++ b/cmd/promtool/testdata/authorization_credentials_file.bad.yml @@ -0,0 +1,4 @@ +scrape_configs: + - job_name: test + authorization: + credentials_file: "/random/file/which/does/not/exist.yml" diff --git a/cmd/promtool/testdata/authorization_credentials_file.good.yml b/cmd/promtool/testdata/authorization_credentials_file.good.yml new file mode 100644 index 0000000000..f6a5a76500 --- /dev/null +++ b/cmd/promtool/testdata/authorization_credentials_file.good.yml @@ -0,0 +1,4 @@ +scrape_configs: + - job_name: test + authorization: + credentials_file: "." From 863788b057c92a913b00db07ee27dabc9cbb18fc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Nov 2021 10:46:18 +0100 Subject: [PATCH 4/8] build(deps): bump github.com/go-openapi/strfmt from 0.21.0 to 0.21.1 (#9900) Bumps [github.com/go-openapi/strfmt](https://github.com/go-openapi/strfmt) from 0.21.0 to 0.21.1. - [Release notes](https://github.com/go-openapi/strfmt/releases) - [Commits](https://github.com/go-openapi/strfmt/compare/v0.21.0...v0.21.1) --- updated-dependencies: - dependency-name: github.com/go-openapi/strfmt dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 99a19e4ea3..2cb0f2af11 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/fsnotify/fsnotify v1.5.1 github.com/go-kit/log v0.2.0 github.com/go-logfmt/logfmt v0.5.1 - github.com/go-openapi/strfmt v0.21.0 + github.com/go-openapi/strfmt v0.21.1 github.com/go-zookeeper/zk v1.0.2 github.com/gogo/protobuf v1.3.2 github.com/golang/snappy v0.0.4 diff --git a/go.sum b/go.sum index cc6535c975..1893021374 100644 --- a/go.sum +++ b/go.sum @@ -547,8 +547,8 @@ github.com/go-openapi/strfmt v0.19.5/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk github.com/go-openapi/strfmt v0.19.11/go.mod h1:UukAYgTaQfqJuAFlNxxMWNvMYiwiXtLsF2VwmoFtbtc= github.com/go-openapi/strfmt v0.20.0/go.mod h1:UukAYgTaQfqJuAFlNxxMWNvMYiwiXtLsF2VwmoFtbtc= github.com/go-openapi/strfmt v0.20.1/go.mod h1:43urheQI9dNtE5lTZQfuFJvjYJKPrxicATpEfZwHUNk= -github.com/go-openapi/strfmt v0.21.0 h1:hX2qEZKmYks+t0hKeb4VTJpUm2UYsdL3+DCid5swxIs= -github.com/go-openapi/strfmt v0.21.0/go.mod h1:ZRQ409bWMj+SOgXofQAGTIo2Ebu72Gs+WaRADcS5iNg= +github.com/go-openapi/strfmt v0.21.1 h1:G6s2t5V5kGCHLVbSdZ/6lI8Wm4OzoPFkc3/cjAsKQrM= +github.com/go-openapi/strfmt v0.21.1/go.mod h1:I/XVKeLc5+MM5oPNN7P6urMOpuLXEcNrCX/rPGuWb0k= github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= @@ -1351,8 +1351,8 @@ go.mongodb.org/mongo-driver v1.4.3/go.mod h1:WcMNYLx/IlOxLe6JRJiv2uXuCz6zBLndR4S go.mongodb.org/mongo-driver v1.4.4/go.mod h1:WcMNYLx/IlOxLe6JRJiv2uXuCz6zBLndR4SoGjYphSc= go.mongodb.org/mongo-driver v1.4.6/go.mod h1:WcMNYLx/IlOxLe6JRJiv2uXuCz6zBLndR4SoGjYphSc= go.mongodb.org/mongo-driver v1.5.1/go.mod h1:gRXCHX4Jo7J0IJ1oDQyUxF7jfy19UfxniMS4xxMmUqw= -go.mongodb.org/mongo-driver v1.7.3 h1:G4l/eYY9VrQAK/AUgkV0koQKzQnyddnWxrd/Etf0jIs= -go.mongodb.org/mongo-driver v1.7.3/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R79oO62zWg= +go.mongodb.org/mongo-driver v1.7.5 h1:ny3p0reEpgsR2cfA5cjgwFZg3Cv/ofFh/8jbhGtz9VI= +go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng= go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1/go.mod h1:SNgMg+EgDFwmvSmLRTNKC5fegJjB7v23qTQ0XLGUNHk= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= From 0d20ee46fe9de548f94d138e7dc035145a972a3f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Nov 2021 10:48:48 +0100 Subject: [PATCH 5/8] build(deps): bump github.com/aws/aws-sdk-go from 1.42.10 to 1.42.15 (#9902) Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.42.10 to 1.42.15. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Changelog](https://github.com/aws/aws-sdk-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.42.10...v1.42.15) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2cb0f2af11..6fd98e1568 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect github.com/Azure/go-autorest/autorest/validation v0.3.1 // indirect github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a - github.com/aws/aws-sdk-go v1.42.10 + github.com/aws/aws-sdk-go v1.42.15 github.com/cespare/xxhash/v2 v2.1.2 github.com/containerd/containerd v1.5.7 // indirect github.com/dennwc/varint v1.0.0 diff --git a/go.sum b/go.sum index 1893021374..0fedb5291a 100644 --- a/go.sum +++ b/go.sum @@ -187,8 +187,8 @@ github.com/aws/aws-sdk-go v1.30.12/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZve github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48= github.com/aws/aws-sdk-go v1.38.35/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go v1.40.11/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q= -github.com/aws/aws-sdk-go v1.42.10 h1:PW9G/hnsuKttbFtOcgNKD0vQrp4yfNrtACA+X0p9mjM= -github.com/aws/aws-sdk-go v1.42.10/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q= +github.com/aws/aws-sdk-go v1.42.15 h1:RcUChuF7KzrrTqx9LAzJbLBX00LkUY7cH9T1VdxNdqk= +github.com/aws/aws-sdk-go v1.42.15/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/benbjohnson/immutable v0.2.1/go.mod h1:uc6OHo6PN2++n98KHLxW8ef4W42ylHiQSENghE1ezxI= github.com/benbjohnson/tmpl v1.0.0/go.mod h1:igT620JFIi44B6awvU9IsDhR77IXWtFigTLil/RPdps= From c78fcd29ba5a46859becf6148401c8e5f1388210 Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Tue, 30 Nov 2021 11:21:07 +0100 Subject: [PATCH 6/8] Adapt UI for Prometheus Agent (#9851) * Adapt UI for Prometheus Agent UI is not my strongest skill, but I'd like to have something minimal for the initial release of the agent. Signed-off-by: Julien Pivotto * Address review comments Signed-off-by: Julien Pivotto * Add tests Signed-off-by: Julien Pivotto * Add tests, serve only current mode paths Signed-off-by: Julien Pivotto * Update js style, add agent test Signed-off-by: Julien Pivotto --- web/ui/react-app/public/index.html | 3 +- web/ui/react-app/src/App.test.tsx | 4 +- web/ui/react-app/src/App.tsx | 12 +++-- web/ui/react-app/src/Navbar.tsx | 55 +++++++++++++--------- web/ui/react-app/src/index.tsx | 4 +- web/ui/react-app/src/pages/agent/Agent.tsx | 16 +++++++ web/ui/react-app/src/pages/index.ts | 3 ++ web/web.go | 36 +++++++++++--- web/web_test.go | 3 ++ 9 files changed, 102 insertions(+), 34 deletions(-) create mode 100644 web/ui/react-app/src/pages/agent/Agent.tsx diff --git a/web/ui/react-app/public/index.html b/web/ui/react-app/public/index.html index eac493853c..a3f7b7a850 100755 --- a/web/ui/react-app/public/index.html +++ b/web/ui/react-app/public/index.html @@ -15,10 +15,11 @@ It will render a "Consoles" link in the navbar when it is non-empty. - PROMETHEUS_AGENT_MODE is replaced by a boolean indicating if Prometheus is running in agent mode. It true, it will disable querying capacities in the UI and generally adapt the UI to the agent mode. + It has to be represented as a string, because booleans can be mangled to !1 in production builds. -->