Commit Graph

546 Commits

Author SHA1 Message Date
Łukasz Mierzwa a4317bf0ec
Run gofumpt on all files (#10392)
* Run gofumpt on all files

Getting golangci-lint errors when building on my laptop, possibly because I have newer version of gofumpt then what it was formatted with.
Run gofumpt -w -extra on all files as it will be needed in the future anyway.

* Update golangci-lint to v1.44.2

v1.44.0 upgraded gofumpt so bumping version in CI will help keep formatting correct for everyone

* Address golangci-lint error

Getting 'error-strings: error strings should not be capitalized or end with punctuation or a newline' from revive here.
Drop new line.

Signed-off-by: Łukasz Mierzwa <l.mierzwa@gmail.com>
2022-03-03 17:21:05 +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
Chris Marchbanks 3e0a0a5d59
Fix Scaleway test
The upgraded client adds order=creation_date_desc to the query
parameters causing the tests to fail. Instead of checking the full URI,
just check that the path is correct.

Signed-off-by: Chris Marchbanks <csmarchbanks@gmail.com>
2022-02-22 12:18:43 -07:00
David N Perkins fcb6f18122
Uyuni login less often (#10072)
* Initial implementation of caching the uyuni login token

Signed-off-by: David N Perkins <David.N.Perkins@ibm.com>
2022-02-15 16:38:38 +01:00
Julien Pivotto 9a2e93228e
Switch to grafana/regexp everywhere (#10268)
Let's have a consistent library for regexp.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2022-02-13 00:58:27 +01:00
Julien Pivotto b0d70557b7
Merge pull request #10285 from prometheus/release-2.33 2022-02-12 00:02:24 +01:00
Julien Pivotto 002ceb7232 Fix panic in Azure SD when no public interface is set.
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2022-02-11 21:25:45 +01:00
johncming 37c6ef9661
discovery/digitalocean: make do api be aware of discovery context. (#10281)
Signed-off-by: johncming <johncming@yahoo.com>
2022-02-11 09:23:51 +01:00
Levi Harrison 1b3443ede1
Azure: Fix panic when IP Address isn't set (#10280) 2022-02-11 00:31:18 +01:00
Björn Rabenstein 5851557a28
Merge pull request #10250 from prometheus/beorn7/cleaning-up-cherrypicking-fallout
Merge release-2.33 forward into main
2022-02-02 17:22:18 +01:00
Robert Fratto 516579a97e
discovery/targetgroup: support marshaling to JSON (#10229)
* discovery/targetgroup: support marshaling to JSON

targetgroup.Group is able to be marshaled to and from YAML, but not with
JSON. JSON is used for the http_sd API representation, so users
implementing the API were required to implement their own type which is
expected by the JSON unmarshaler.

Signed-off-by: Robert Fratto <robertfratto@gmail.com>

* fix lint error

Signed-off-by: Robert Fratto <robertfratto@gmail.com>

* Update discovery/targetgroup/targetgroup.go

Co-authored-by: Julius Volz <julius.volz@gmail.com>
Signed-off-by: Robert Fratto <robertfratto@gmail.com>

* s/Json/JSON

Signed-off-by: Robert Fratto <robertfratto@gmail.com>

Co-authored-by: Julius Volz <julius.volz@gmail.com>
2022-02-02 17:20:18 +01: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
Julien Pivotto 18d737de3e
Azure SD: Set Prometheus user agent (#10209)
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2022-01-28 13:36:04 +01:00
Eng Zer Jun 3e67654d37
refactor: use `T.TempDir()` and `B.TempDir` to create temporary directory
The directory created by `T.TempDir()` and `B.TempDir()` is
automatically removed when the test and all its subtests complete.

Reference: https://pkg.go.dev/testing#T.TempDir
Reference: https://pkg.go.dev/testing#B.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-01-22 18:57:30 +08:00
Shihao Xia d26fd5c97b
fix potential goroutine leaks (#10057)
Signed-off-by: Shihao Xia <charlesxsh@hotmail.com>
2022-01-05 16:21:06 +05:30
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
Witek Bedyk 14986e52cf
Fix Uyuni SD initialization (#9924)
* Fix Uyuni SD initialization

The change prevents null pointer exception during SD initialization.

Signed-off-by: Witek Bedyk <witold.bedyk@suse.com>
2021-12-04 21:14:47 +01:00
Augustin Husson d140df2335
replace gopkg.in/fsnotify/fsnotify.v1 by github.com/fsnotify/fsnotify (#9781)
Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
2021-11-17 13:07:14 +01:00
Dieter Plaetinck 0fac9bb859
Add basic initial developer docs for TSDB (#9451)
* Add basic initial developer docs for TSDB

There's a decent amount of content already out there (blog posts,
conference talks, etc), but:
* when they get stale, they don't tend to get updated
* they still leave me with questions that I'ld like to answer
  for developers (like me) who want to use, or work with, TSDB

What I propose is developer docs inside the prometheus
repository.  Easy to find and harness the power of the community
to expand it and keep it up to date.

* perfect is the enemy of good.  Let's have a base and incrementally improve
* Markdown docs should be broad but not too deep.  Source code comments
  can complement them, and are the ideal place for implementation details.

Signed-off-by: Dieter Plaetinck <dieter@grafana.com>

* use example code that works out of the box

Signed-off-by: Dieter Plaetinck <dieter@grafana.com>

* Apply suggestions from code review

Co-authored-by: Ganesh Vernekar <15064823+codesome@users.noreply.github.com>
Signed-off-by: Dieter Plaetinck <dieter@grafana.com>

* PR feedback

Signed-off-by: Dieter Plaetinck <dieter@grafana.com>

* more docs

Signed-off-by: Dieter Plaetinck <dieter@grafana.com>

* PR feedback

Signed-off-by: Dieter Plaetinck <dieter@grafana.com>

* Apply suggestions from code review

Signed-off-by: Dieter Plaetinck <dieter@grafana.com>

Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Apply suggestions from code review

Signed-off-by: Dieter Plaetinck <dieter@grafana.com>

Co-authored-by: Ganesh Vernekar <15064823+codesome@users.noreply.github.com>

* feedback

Signed-off-by: Dieter Plaetinck <dieter@grafana.com>

* Update tsdb/docs/usage.md

Signed-off-by: Dieter Plaetinck <dieter@grafana.com>

Co-authored-by: Ganesh Vernekar <15064823+codesome@users.noreply.github.com>

* final tweaks

Signed-off-by: Dieter Plaetinck <dieter@grafana.com>

* workaround docs versioning issue

Signed-off-by: Dieter Plaetinck <dieter@grafana.com>

* Move example code to real executable, testable example.

Signed-off-by: Dieter Plaetinck <dieter@grafana.com>

* cleanup example test and make sure it always reproduces

Signed-off-by: Dieter Plaetinck <dieter@grafana.com>

* obtain temp dir in a way that works with older Go versions

Signed-off-by: Dieter Plaetinck <dieter@grafana.com>

* Fix Ganesh's comments

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

Co-authored-by: Ganesh Vernekar <15064823+codesome@users.noreply.github.com>
Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
Co-authored-by: Ganesh Vernekar <ganeshvern@gmail.com>
2021-11-17 15:51:27 +05:30
TJ Hoplock 377bdffdbe
feat: tune api requrest page sizes in linode SD (#9779) 2021-11-16 18:02:27 -05:00
TJ Hoplock e3d0333a3b
fix: linode SD tests (#9773)
* build(deps): bump github.com/linode/linodego from 1.1.0 to 1.2.1
* fix: linode SD tests

This fixes failing builds due to the version bump of linodego to
`v1.2.1`.

Fixes:
https://github.com/prometheus/prometheus/pull/9763

See also:
https://github.com/linode/linodego/issues/226
https://github.com/linode/linodego/pull/227
https://github.com/linode/linodego/releases/tag/v1.2.1

Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
2021-11-16 23:42:30 +01:00
Mateusz Gozdek 0bfef847b0 discovery/consul: fix leaking goroutine from test
Signed-off-by: Mateusz Gozdek <mgozdekof@gmail.com>
2021-11-10 09:40:43 +01:00
Mateusz Gozdek 4ef8c7c1d8 discovery/xds: make each test use separate HTTP resource config
So tests can run in parallel without races.

Signed-off-by: Mateusz Gozdek <mgozdekof@gmail.com>
2021-11-10 09:40:43 +01:00
Mateusz Gozdek fedcb8999b discovery/marathon: make test use separate instances of config
So tests can be executed in parallel without producing races.

Signed-off-by: Mateusz Gozdek <mgozdekof@gmail.com>
2021-11-10 09:40:43 +01:00
beorn7 a1e595edac Fix two trivial lint warnings
Not sure why those show up for me locally but not if run by the CI.

Signed-off-by: beorn7 <beorn@grafana.com>
2021-11-08 22:32:13 +01:00
Conor Evans c28b9a0574
Add datacenter to Consul service discovery logs (#9668)
* add datacenter to consul service discovery logs

Signed-off-by: Conor Evans <coevans@tcd.ie>
2021-11-08 09:34:21 +01:00
Julien Pivotto b9c814fce6
Merge pull request #9681 from prometheus/release-2.31
merge back release 2.31
2021-11-05 21:21:04 +01:00
Julien Pivotto 9621c2c0cc
Fix race with targets update during ApplyConfig (#9656)
I ended up extending the lock so refTargets remains valid for the
duration of the update.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2021-11-05 01:13:04 +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
lzhfromustc d42be7be76
test:Fix two potential goroutine leaks (#8964)
Signed-off-by: lzhfromustc <lzhfromustc@gmail.com>
2021-10-29 15:44:32 -07:00
Julien Pivotto 73255e15f6 Address golint failures from revive
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2021-10-23 00:53:11 +02:00
Levi Harrison 89a6ebd799
Add common HTTP client to Azure SD (#9267)
* Add `proxy_url` option to Azure SD

Signed-off-by: Levi Harrison <git@leviharrison.dev>
2021-10-20 23:09:58 +02:00
Vladimir Kononov 1043d2b594
Discovery: abstain from restarting providers if possible (#9321) (#9349)
* Abstain from restarting discovery providers if possible (#9321)

Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com>
2021-10-20 10:16:20 +02:00
Julien Pivotto 432005826d
Add a feature flag to enable the new discovery manager (#9537)
* Add a feature flag to enable the new manager

This PR creates a copy of the legacy manager and uses it by default.

It is a companion PR to #9349. With this PR, users can enable the new
discovery manager and provide us with any feedback / side effects that
the new behaviour might have.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2021-10-20 10:15:54 +02:00
Julien Pivotto 68bc92b520
uyuni: small fixes for comments (#9538)
* uyuni: small fixes for comments

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2021-10-19 23:38:44 +02:00
Julien Pivotto 2a574bf8c2
Uyuni: enable HTTP2 again (#9539)
PR #9398 re-introduced HTTP2 in Prometheus. Uyuni SD can use the client
without disabling it.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2021-10-19 21:26:39 +02:00
Witek Bedyk cda2dbbef6
Add Uyuni service discovery (#8190)
* Add Uyuni service discovery

Signed-off-by: Witek Bedyk <witold.bedyk@suse.com>

Co-authored-by: Joao Cavalheiro <jcavalheiro@suse.de>
Co-authored-by: Marcelo Chiaradia <mchiaradia@suse.com>
Co-authored-by: Stefano Torresi <stefano@torresi.io>
Co-authored-by: Julien Pivotto <roidelapluie@gmail.com>
2021-10-19 01:00:44 +02: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 1681a8d539
Azure: Fix panic when no computername is set (#9387)
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2021-09-25 00:30:18 +02:00
Julien Pivotto 8920024323 Add PuppetDB service discovery
We have been Puppet user for 10 years and we are users of
https://github.com/camptocamp/prometheus-puppetdb-sd

However, that file_sd implementation contains business logic and
assumptions around e.g. the modules which you are using.

This pull request adds a simple PuppetDB service discovery, which will
enable more use cases than the upstream sd.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2021-09-16 16:54:26 +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