Commit graph

141 commits

Author SHA1 Message Date
Matthieu MOREL e2ede285a2
refactor: move from io/ioutil to io and os packages (#10528)
* refactor: move from io/ioutil to io and os packages
* use fs.DirEntry instead of os.FileInfo after os.ReadDir

Signed-off-by: MOREL Matthieu <matthieu.morel@cnp.fr>
2022-04-27 11:24:36 +02:00
nixargh e76c6aac50 Fix #10507: explicitly include gcp auth from k8s.io to kubernetes discovery
Signed-off-by: nixargh <nixargh@protonmail.com>
2022-04-01 14:56:37 +03:00
Furkan 2939966634
Kubernetes SD: Support discovery.k8s.io/v1 EndpointSlice
Fixes #9498

Signed-off-by: Furkan <furkan.turkal@trendyol.com>
Signed-off-by: Erkan Zileli <erkan.zileli@trendyol.com>
Co-authored-by: Batuhan Apaydin <batuhan.apaydin@trendyol.com>
2022-03-19 00:42:16 +03:00
fpetkovski 16bd0d7d5c
Index pods by node name
Signed-off-by: fpetkovski <filip.petkovsky@gmail.com>
2022-03-10 15:34:56 +01:00
fpetkovski fa798d3042
Allow attaching node metadata
Signed-off-by: fpetkovski <filip.petkovsky@gmail.com>
2022-03-10 08:40:52 +01:00
cui fliter c9b56d1a49
all: fix some typos (#10389)
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-03-03 12:03:07 +00:00
beorn7 35010daa90 Merge branch 'release-2.33' into beorn7/cleaning-up-cherrypicking-fallout 2022-02-02 16:49:40 +01:00
Julien Pivotto 9d63502204 k8s: improve 'own_namespace'
Fail configuration unmarshalling if kubeconfig or api url are set with
"own namespace"

Only read namespace file if needed.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2022-02-01 14:59:09 +01:00
Georg Gadinger c85efa02d9 Fix k8s target discovery when not running inside k8s
When using Kubernetes service discovery on a Prometheus instance that's
not running inside Kubernetes, the creation of the service discovery
fails with a "no such file or directory" error as the special
`/var/run/secrets/kubernetes.io/serviceaccount/namespace` file is not
there.  This commit moves the code that reads this file into the
if-branch where no `APIServer.URL` is given (that one basically makes
Prometheus assume it is running inside of a Kubernetes cluster).

Signed-off-by: Georg Gadinger <nilsding@nilsding.org>
2022-02-01 14:41:25 +01:00
Georg Gadinger 4663f814d6 Fix k8s target discovery when not running inside k8s
When using Kubernetes service discovery on a Prometheus instance that's
not running inside Kubernetes, the creation of the service discovery
fails with a "no such file or directory" error as the special
`/var/run/secrets/kubernetes.io/serviceaccount/namespace` file is not
there.  This commit moves the code that reads this file into the
if-branch where no `APIServer.URL` is given (that one basically makes
Prometheus assume it is running inside of a Kubernetes cluster).

Signed-off-by: Georg Gadinger <nilsding@nilsding.org>
2022-02-01 10:20:03 +01:00
fpetkovski de87515b24 Implement target discovery in own k8s namespace
This commit adds support for discovering targets from the same
Kubernetes namespace as the Prometheus pod itself. Own-namespace
discovery can be indicated by using "." as the namespace.

Fixes #9782

Signed-off-by: fpetkovski <filip.petkovsky@gmail.com>
2021-12-14 13:41:38 +01:00
Ed Schouten a3e9628e0c
Kubernetes service discovery: add provider ID label (#9603)
When using Kubernetes on cloud providers, nodes will have the
spec.providerID field populated to contain the cloud provider specific
name of the EC2/GCE/...  instance.

Let's expose this information as an additional label, so that it's
easier to annotate metrics and alerts to contain the cloud provider
specific name of the instance to which it pertains.

Signed-off-by: Ed Schouten <eschouten@apple.com>
2021-12-06 22:27:11 +01:00
Mateusz Gozdek ea924746b3
discovery/kubernetes: improve test logic for waiting for discoverers (#9584)
When running tests in parallel, 10 milliseconds may not be enough for
all discoverers to register, which will make test flaky.

This commit changes the waiting logic to wait for number of discoverers
to stop increasing during given time frame, which should be large enough
for single discoverer to register in test environment.

A following run passes with this commit:

go test -failfast -race -count 100 -v ./discovery/kubernetes/

Signed-off-by: Mateusz Gozdek <mgozdekof@gmail.com>
2021-11-02 22:17:32 +01:00
Mateusz Gozdek b7bdf6fab2 Fix imports formatting
According to
2829908806 (r58457095).

Signed-off-by: Mateusz Gozdek <mgozdekof@gmail.com>
2021-11-02 19:52:34 +01:00
Mateusz Gozdek 1a6c2283a3 Format Go source files using 'gofumpt -w -s -extra'
Part of #9557

Signed-off-by: Mateusz Gozdek <mgozdekof@gmail.com>
2021-11-02 19:52:34 +01:00
akatsadimas ee77a6212f discovery/kubernetes: issue overcapacity warning for endpoint rather than endpointslice
Signed-off-by: akatsadimas <nkatsadim@gmail.com>
2021-10-08 23:17:04 +03:00
akatsadimas dd2e666a8d discovery/kubernetes: Warn user in case of endpoint over-capacity
Signed-off-by: akatsadimas <nkatsadim@gmail.com>
2021-10-07 00:01:46 +03:00
Julien Pivotto 63b3e4e5ec
Enable HTTP2 again (#9398)
We are re-enabling HTTP 2 again. There has been a few bugfixes upstream
in go, and we have also enabled ReadIdleTimeout.

Fix #7588
Fix #9068

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2021-09-26 23:16:12 +02:00
Julien Pivotto b1bdde46c3 kubernetes ingress: adjust comment style
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2021-08-30 22:34:24 +02:00
Philip Gough 0af7250c52 discovery:kube: Support wildcard matching for ingress rules
This change sets the scheme to https when a rule specified by Ingress
matches a wildcard DNS entry in the ingress TLS hosts

Signed-off-by: Philip Gough <philip.p.gough@gmail.com>
2021-08-26 14:32:11 +01:00
Takashi Kusumi 3ab8559d1c Kubernetes SD: Fix golint issue
Signed-off-by: Takashi Kusumi <tkusumi@zlab.co.jp>
2021-08-24 17:30:33 +09:00
Takashi Kusumi 40981c422b Kubernetes SD: Introduce ingressAdaptor
Signed-off-by: Takashi Kusumi <tkusumi@zlab.co.jp>
2021-08-20 17:06:17 +09:00
Takashi Kusumi 6634a570cf Kubernetes SD: Support networking.k8s.io/v1 Ingress
Signed-off-by: Takashi Kusumi <tkusumi@zlab.co.jp>
2021-08-16 08:35:42 +09:00
3Xpl0it3r a0bac4b488
add kubeconfig support in discovery module (#8811)
Signed-off-by: 3Xpl0it3r <shouc.wang@hotmail.com>
2021-06-17 12:41:50 +02:00
Frederic Branczyk 039b651450
Merge pull request #8916 from Evesy/main
Add class label to kubernetes ingress discovery
2021-06-14 13:40:08 +02:00
Levi Harrison b5f6f8fb36 Switched to go-kit/log
Signed-off-by: Levi Harrison <git@leviharrison.dev>
2021-06-11 12:28:36 -04:00
Mike Eves ae081886fa Fix up tests
Signed-off-by: Mike Eves <michael.eves@autotrader.co.uk>
2021-06-11 15:49:13 +01:00
Mike Eves 7941b350ba Don't set label if ingressClassName is not set
Signed-off-by: Mike Eves <michael.eves@autotrader.co.uk>
2021-06-11 15:14:23 +01:00
Mike Eves 7e1111ff14 Update label from class to class_name
Signed-off-by: Mike Eves <michael.eves@autotrader.co.uk>
2021-06-11 13:45:41 +01:00
Mike Eves 7e65ad3e43 Add class label to kubernetes ingress discovery
Signed-off-by: Mike Eves <michael.eves@autotrader.co.uk>
2021-06-11 11:27:15 +01:00
kongxs 632678a461
Fix spelling mistake (#8879)
* Fix spelling mistake

Signed-off-by: kjinan <2008kongxiangsheng@163.com>

* Update discovery/kubernetes/endpoints.go

Co-authored-by: Julien Pivotto <roidelapluie@gmail.com>
Signed-off-by: kjinan <2008kongxiangsheng@163.com>

Co-authored-by: Julien Pivotto <roidelapluie@gmail.com>
2021-06-01 00:49:29 +02:00
Marco Pracucci 4da5c25ea4
Upgrade prometheus/common to v0.21.0
Signed-off-by: Marco Pracucci <marco@pracucci.com>
2021-04-21 12:19:16 +02:00
Bogdan Drutu d1ced85d7a
Bump k8s.io/* from 0.20.5 to 0.21.0 (#8714)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2021-04-13 10:00:00 +02:00
Julien Pivotto 93c6139bc1 Support follow_redirect
This PR introduces support for follow_redirect, to enable users to
disable following HTTP redirects.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2021-02-26 22:50:56 +01:00
fuling 829b939891 [fix] service discovery : change var "eps" to "pod
Signed-off-by: fuling <fuling.lgz@alibaba-inc.com>
2021-02-10 20:17:04 +08:00
Frederic Branczyk 19b0ec3baf
Merge pull request #8273 from fcddk/fcddk-k8s-enpoints-label
K8s SD: add endpoints labels metadata
2021-01-04 17:25:27 +01:00
fcddk b270a1d6bf import strutil package
import strutil package

Signed-off-by: root <likerj@inspur.com>
2020-12-16 16:27:03 +08:00
fcddk 617c56f55a add endponits labels metadata
add endponits labels metadata

Signed-off-by: root <likerj@inspur.com>
2020-12-16 16:07:49 +08:00
Alexey Shumkin 73ddf603af
discovery/kubernetes: Fix valid label selector causing config error
Label selector can be
"set-based"(https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#set-based-requirement)
but such a selector causes Prometheus start failure with the "unexpected
error: parsing YAML file ...: invalid selector: 'foo in (bar,baz)';
can't understand 'baz)'"-like error.

This is caused by the `fields.ParseSelector(string)` function that
simply splits an expression as a CSV-list, so a comma confuses such a
parsing method and lead to the error.

Use `labels.Parse(string)` to use a valid lexer to parse a selector
expression.

Closes #8284.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
2020-12-16 10:56:01 +03:00
Julien Pivotto 6c56a1faaa
Testify: move to require (#8122)
* Testify: move to require

Moving testify to require to fail tests early in case of errors.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>

* More moves

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2020-10-29 09:43:23 +00:00
Julien Pivotto 4e5b1722b3
Move away from testutil, refactor imports (#8087)
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2020-10-22 11:00:08 +02:00
Andy Bursavich 4e6a94a27d
Invert service discovery dependencies (#7701)
This also fixes a bug in query_log_file, which now is relative to the config file like all other paths.

Signed-off-by: Andy Bursavich <abursavich@gmail.com>
2020-08-20 13:48:26 +01:00
Frederic Branczyk 06e2c2f804
Merge pull request #6838 from brancz/endpointslice
discovery/kubernetes: EndpointSlice discovery
2020-08-12 16:42:49 +02:00
johncming 3c5ff27959
Update http header User-Agent in k8s and swarm discovery. (#7614)
* discovery: update k8s and swarm user agent.

Signed-off-by: johncming <johncming@yahoo.com>
2020-07-31 00:18:38 +02:00
Julien Pivotto 3e0ec3f8e1 Minor change
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2020-07-29 22:14:23 +02:00
Julien Pivotto e76c436e9c
Goleak in discoveries, scrape, rules (#7662)
* Add go leak tests for discoveries with goroutines

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>

* Add go leak tests in rules

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>

* Add go leak tests in scrape tests

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2020-07-27 09:38:08 +01:00
Frederic Branczyk f6c5a75661 discovery/kubernetes: Add Kubernetes EndpointSlice discovery
Signed-off-by: Frederic Branczyk <fbranczyk@gmail.com>
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2020-06-14 21:55:27 +02:00
Frederic Branczyk 7b1c0d6b66
discovery/kubernetes: Fix incorrect premature break of reading results
Previously `max` results stopped reading from results in tests
prematurely, as it stopped when `max` number of items were received from
the channel instead of `max` number of unique target groups received.
This caused flaky tests where the same target group was received
multiple times, as Kubernetes informers may emit the same event multiple
times.

Before this patch, running this test repeatedly failed eventually. After
this patch I have run the test many thousand times without failure.

```bash
go test -run TestEndpointsDiscoveryNamespaces -count 1000 -test.v
```

Signed-off-by: Frederic Branczyk <fbranczyk@gmail.com>
2020-06-11 16:08:28 +02:00
Tariq Ibrahim 06a6621b6c
update kubernetes to v1.18.x and update ingress apiVersion
Signed-off-by: Tariq Ibrahim <tariq181290@gmail.com>
2020-06-01 08:26:50 -07:00
Tariq Ibrahim 0730d6eb74
remove deprecated methods from the MetricProvider interface
Signed-off-by: Tariq Ibrahim <tariq181290@gmail.com>
2020-04-06 09:23:58 -07:00