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

Sync upstream to current HEAD at e2f037e554a8a336ca4487324dd4ceee893fda0a #792

Merged
merged 100 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
90e832c
scrape: fix nil panic after scrape loop reload
GiedriusS Dec 2, 2024
8d4bcd2
promql: Fix various UTF-8 bugs related to quoting
ywwg Dec 3, 2024
5479fb3
scrape: update test after review
GiedriusS Dec 9, 2024
eeef17e
docs: Added native histogram WAL record documentation.
bwplotka Dec 9, 2024
664177b
Merge pull request #15554 from prometheus/waldocs
bwplotka Dec 9, 2024
fe4e817
chore: fix some function names in comment
avoidaway Dec 9, 2024
6c8163e
Merge pull request #15556 from avoidaway/main
ArthurSens Dec 9, 2024
5d76510
scrape: update test name
GiedriusS Dec 9, 2024
0a77294
RELEASE.md: schedule 3.[1,2,3,4] releases
jan--f Dec 5, 2024
437362a
fix(deduper): use ptr to sync.RWMutex, fix panic during concurrent use
tjhop Dec 10, 2024
a70cba8
Merge pull request #15562 from tjhop/fix/dedupe-logger-concurrent-map…
bwplotka Dec 10, 2024
addaf41
Merge pull request #15542 from jan--f/schedule-3.1
bboreham Dec 10, 2024
c69aeab
Merge pull request #15563 from GiedriusS/fix_setting_field
bboreham Dec 10, 2024
f61e66a
chore(deps-dev): bump globals from 15.10.0 to 15.13.0 in /web/ui (#15…
dependabot[bot] Dec 10, 2024
35047db
chore(deps): bump @tanstack/react-query from 5.59.0 to 5.62.0 in /web…
dependabot[bot] Dec 10, 2024
7d4096d
chore(deps): bump @codemirror/language from 6.10.2 to 6.10.6 in /web/…
dependabot[bot] Dec 10, 2024
6539d2c
chore(deps-dev): bump @eslint/js from 9.11.1 to 9.16.0 in /web/ui (#1…
dependabot[bot] Dec 10, 2024
2fe71b4
chore(deps-dev): bump @vitejs/plugin-react in /web/ui (#15517)
dependabot[bot] Dec 10, 2024
7afd2f1
chore(deps): bump react-router-dom from 6.26.2 to 7.0.1 in /web/ui (#…
dependabot[bot] Dec 10, 2024
0ae424d
chore(deps): bump @mantine/code-highlight in /web/ui (#15515)
dependabot[bot] Dec 10, 2024
64dd707
Add old UI to dependabot
SuperQ Dec 10, 2024
3a4e771
Merge pull request #15531 from prometheus/owilliams/promqltest
beorn7 Dec 10, 2024
6daf75d
chore(deps): bump @types/lodash from 4.17.9 to 4.17.13 in /web/ui (#1…
dependabot[bot] Dec 10, 2024
f0077f0
chore(deps-dev): bump @types/jest from 29.5.13 to 29.5.14 in /web/ui …
dependabot[bot] Dec 10, 2024
ee18650
chore(deps-dev): bump @eslint/compat from 1.1.1 to 1.2.4 in /web/ui (…
dependabot[bot] Dec 10, 2024
018f4f3
chore(deps): bump @reduxjs/toolkit from 2.2.7 to 2.4.0 in /web/ui (#1…
dependabot[bot] Dec 10, 2024
8784e28
chore(deps): bump sanitize-html from 2.13.0 to 2.13.1 in /web/ui (#15…
dependabot[bot] Dec 10, 2024
2c279de
chore(deps): bump @testing-library/jest-dom in /web/ui (#15276)
dependabot[bot] Dec 10, 2024
6674991
chore(deps): bump uplot from 1.6.30 to 1.6.31 in /web/ui (#15277)
dependabot[bot] Dec 10, 2024
1055502
chore(deps): bump @lezer/common from 1.2.1 to 1.2.3 in /web/ui (#15278)
dependabot[bot] Dec 10, 2024
faf398e
chore(deps): bump @uiw/react-codemirror from 4.23.3 to 4.23.6 in /web…
dependabot[bot] Dec 10, 2024
431fb1a
chore(deps): bump google.golang.org/api from 0.204.0 to 0.209.0 (#15501)
dependabot[bot] Dec 10, 2024
d1c251f
chore(deps): bump github.com/ionos-cloud/sdk-go/v6 from 6.2.1 to 6.3.…
dependabot[bot] Dec 10, 2024
944c804
chore(deps): bump google.golang.org/grpc from 1.67.1 to 1.68.1 (#15576)
dependabot[bot] Dec 11, 2024
e1bfdd2
chore(deps-dev): bump eslint-plugin-react-hooks in /web/ui (#15568)
dependabot[bot] Dec 11, 2024
b0e7de1
promqltest: allow running tests with custom storage implementation
achille-roussel Dec 11, 2024
5cc095e
Merge pull request #15571 from prometheus/superq/dependabot_old_ui
bwplotka Dec 11, 2024
ebfa1dd
promql: Purge Holt-Winters from a doc comment
beorn7 Dec 11, 2024
f44bba3
config: Remove validation GetScrapeConfigs; require using config.Load.
bwplotka Dec 11, 2024
9895d88
OTLP receiver: Use stdlib for splitting metric name in classical mode…
aknuds1 Dec 11, 2024
dd147ec
chore(deps): bump @codemirror/view in /web/ui/react-app (#15609)
dependabot[bot] Dec 11, 2024
9438966
chore(deps-dev): bump @types/jest in /web/ui/react-app (#15631)
dependabot[bot] Dec 11, 2024
a976b8b
chore(deps): bump @mantine/code-highlight in /web/ui (#15630)
dependabot[bot] Dec 11, 2024
29846dd
chore(deps-dev): bump eslint from 9.11.1 to 9.16.0 in /web/ui (#15628)
dependabot[bot] Dec 11, 2024
cfb54fa
chore(deps-dev): bump @testing-library/react-hooks in /web/ui/react-a…
dependabot[bot] Dec 11, 2024
3c99111
chore(deps-dev): bump eslint-plugin-react-refresh in /web/ui (#15602)
dependabot[bot] Dec 11, 2024
c4ed196
chore(deps): bump @codemirror/language in /web/ui/react-app (#15621)
dependabot[bot] Dec 11, 2024
4ac6032
chore(deps-dev): bump sinon from 18.0.0 to 19.0.2 in /web/ui/react-ap…
dependabot[bot] Dec 11, 2024
7294aea
chore(deps-dev): bump @rollup/plugin-node-resolve in /web/ui (#15270)
dependabot[bot] Dec 11, 2024
45d3d2e
chore(deps-dev): bump @eslint/eslintrc from 3.1.0 to 3.2.0 in /web/ui…
dependabot[bot] Dec 11, 2024
16f4adb
chore(deps-dev): bump @lezer/generator from 1.7.1 to 1.7.2 in /web/ui…
dependabot[bot] Dec 11, 2024
3071349
chore(deps-dev): bump prettier from 3.3.3 to 3.4.2 in /web/ui (#15620)
dependabot[bot] Dec 11, 2024
f0c9154
chore(deps): bump @reduxjs/toolkit from 2.4.0 to 2.5.0 in /web/ui (#1…
dependabot[bot] Dec 11, 2024
e07de08
chore(deps): bump @codemirror/lint from 6.8.1 to 6.8.4 in /web/ui (#1…
dependabot[bot] Dec 11, 2024
ab3681f
chore(deps): bump lru-cache from 11.0.1 to 11.0.2 in /web/ui (#15596)
dependabot[bot] Dec 11, 2024
8b716e3
chore(deps-dev): bump vitest from 2.1.1 to 2.1.8 in /web/ui (#15591)
dependabot[bot] Dec 11, 2024
e62a737
chore(deps): bump @codemirror/search in /web/ui/react-app
dependabot[bot] Dec 11, 2024
9cf597c
Merge pull request #15635 from prometheus/beorn7/promql
jan--f Dec 11, 2024
b9e2ac0
Merge pull request #15632 from prometheus/dependabot/npm_and_yarn/web…
bwplotka Dec 11, 2024
a940deb
chore(deps-dev): bump @types/jquery in /web/ui/react-app (#15590)
dependabot[bot] Dec 11, 2024
c66d78c
chore(deps-dev): bump vite from 5.4.8 to 6.0.3 in /web/ui (#15611)
dependabot[bot] Dec 11, 2024
d33019e
chore(deps): bump @fortawesome/react-fontawesome in /web/ui/react-app…
dependabot[bot] Dec 11, 2024
f451246
chore(deps): bump downshift from 9.0.6 to 9.0.8 in /web/ui/react-app …
dependabot[bot] Dec 11, 2024
ee33890
chore(deps): bump @testing-library/react in /web/ui (#15588)
dependabot[bot] Dec 11, 2024
4cbf44e
chore(deps): bump @floating-ui/dom from 1.6.10 to 1.6.12 in /web/ui (…
dependabot[bot] Dec 11, 2024
da53bad
chore(deps): bump @codemirror/commands in /web/ui/react-app (#15612)
dependabot[bot] Dec 11, 2024
f7fec4d
chore(deps): bump @nexucis/fuzzy in /web/ui/react-app (#15629)
dependabot[bot] Dec 11, 2024
b10d5e0
chore(deps): bump sass from 1.77.6 to 1.82.0 in /web/ui/react-app (#1…
dependabot[bot] Dec 11, 2024
077d4ed
chore(deps): bump @lezer/common from 1.2.1 to 1.2.3 in /web/ui/react-…
dependabot[bot] Dec 11, 2024
28e611a
chore(deps): bump http-proxy-middleware in /web/ui/react-app (#15610)
dependabot[bot] Dec 11, 2024
8df0548
chore(deps): bump moment-timezone in /web/ui/react-app (#15641)
dependabot[bot] Dec 11, 2024
cc4fcc1
chore(deps-dev): bump nock from 13.5.5 to 13.5.6 in /web/ui (#15642)
dependabot[bot] Dec 11, 2024
00e0cdc
chore(deps): bump @mantine/dates from 7.13.1 to 7.15.0 in /web/ui (#1…
dependabot[bot] Dec 11, 2024
ec95602
chore(deps): bump @lezer/highlight in /web/ui/react-app (#15660)
dependabot[bot] Dec 11, 2024
d6a24b2
chore(deps): bump @mantine/notifications in /web/ui (#15658)
dependabot[bot] Dec 11, 2024
bb54eaf
chore(deps): bump @nexucis/kvsearch in /web/ui/react-app (#15659)
dependabot[bot] Dec 11, 2024
032391a
chore(deps): bump @codemirror/autocomplete in /web/ui/react-app (#15649)
dependabot[bot] Dec 11, 2024
4b142dc
chore(deps-dev): bump typescript from 5.6.2 to 5.7.2 in /web/ui (#15650)
dependabot[bot] Dec 11, 2024
9362ba3
chore(deps-dev): bump @types/node in /web/ui/react-app (#15651)
dependabot[bot] Dec 11, 2024
5aa80fb
chore(deps): bump react-router-dom from 7.0.1 to 7.0.2 in /web/ui (#1…
dependabot[bot] Dec 11, 2024
db36cbc
chore(deps): bump @tanstack/react-query from 5.62.0 to 5.62.7 in /web…
dependabot[bot] Dec 11, 2024
94aa9e9
chore(deps): bump sanitize-html and @types/sanitize-html (#15663)
dependabot[bot] Dec 12, 2024
463dd3e
chore(deps): bump @codemirror/autocomplete in /web/ui (#15656)
dependabot[bot] Dec 12, 2024
f232699
chore(deps-dev): bump ts-jest from 29.2.2 to 29.2.5 in /web/ui/react-…
dependabot[bot] Dec 12, 2024
abddce3
chore(deps): bump @tabler/icons-react from 3.19.0 to 3.24.0 in /web/u…
dependabot[bot] Dec 12, 2024
9f93a2a
chore(deps): bump react-redux from 9.1.2 to 9.2.0 in /web/ui (#15645)
dependabot[bot] Dec 12, 2024
987b42f
chore(deps): bump @codemirror/lint in /web/ui/react-app (#15647)
dependabot[bot] Dec 12, 2024
6910277
chore(deps): bump @prometheus-io/codemirror-promql in /web/ui/react-a…
dependabot[bot] Dec 12, 2024
3c6700b
chore(deps): bump golang.org/x/tools from 0.27.0 to 0.28.0 (#15593)
dependabot[bot] Dec 12, 2024
ceeab58
chore(deps): bump github.com/prometheus/common from 0.60.1 to 0.61.0
dependabot[bot] Dec 12, 2024
aa9fef7
Apply suggestions from code review
bwplotka Dec 12, 2024
b7f5f36
Merge pull request #15604 from prometheus/dependabot/go_modules/githu…
bwplotka Dec 12, 2024
134a0c7
Improved error.
bwplotka Dec 12, 2024
7d0f6b7
Add specific Azure permissions required for Azure SD (#15549)
jeremiahharbach Dec 12, 2024
fec7ca0
Merge pull request #15637 from prometheus/fix15538-2
bwplotka Dec 12, 2024
791df43
Merge pull request #15668 from firetiger-inc/promqltest-with-storage
bwplotka Dec 13, 2024
9009724
[BUGFIX] PromQL: Adds test for `absent`, `absent_over_time` and `deri…
NeerajGartia21 Dec 13, 2024
7802ca2
RuleDependencyController: Fix for indeterminate conditions (#15560)
julienduchesne Dec 13, 2024
e2f037e
rules: Add new `RuleEvaluationTimeSum` field to groups (#15672)
julienduchesne Dec 13, 2024
dbdc94f
Merge commit 'e2f037e554a8a336ca4487324dd4ceee893fda0a' into juliendu…
julienduchesne Dec 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ updates:
open-pull-requests-limit: 0
- package-ecosystem: "npm"
directory: "/web/ui"
labels:
- dependencies
- javascript
- manteen-ui
schedule:
interval: "monthly"
open-pull-requests-limit: 20
# Old react-app packages.
- package-ecosystem: "npm"
directory: "/web/ui/react-app"
labels:
- dependencies
- javascript
- old-react-ui
schedule:
interval: "monthly"
open-pull-requests-limit: 0
Expand Down
64 changes: 9 additions & 55 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,15 @@ This page describes the release process and the currently planned schedule for u
## Release schedule

Release cadence of first pre-releases being cut is 6 weeks.
Please see [the v2.55 RELEASE.md](https://github.com/prometheus/prometheus/blob/release-2.55/RELEASE.md) for the v2 release series schedule.

| release series | date of first pre-release (year-month-day) | release shepherd |
|----------------|--------------------------------------------|---------------------------------------------|
| v2.4 | 2018-09-06 | Goutham Veeramachaneni (GitHub: @gouthamve) |
| v2.5 | 2018-10-24 | Frederic Branczyk (GitHub: @brancz) |
| v2.6 | 2018-12-05 | Simon Pasquier (GitHub: @simonpasquier) |
| v2.7 | 2019-01-16 | Goutham Veeramachaneni (GitHub: @gouthamve) |
| v2.8 | 2019-02-27 | Ganesh Vernekar (GitHub: @codesome) |
| v2.9 | 2019-04-10 | Brian Brazil (GitHub: @brian-brazil) |
| v2.10 | 2019-05-22 | Björn Rabenstein (GitHub: @beorn7) |
| v2.11 | 2019-07-03 | Frederic Branczyk (GitHub: @brancz) |
| v2.12 | 2019-08-14 | Julius Volz (GitHub: @juliusv) |
| v2.13 | 2019-09-25 | Krasi Georgiev (GitHub: @krasi-georgiev) |
| v2.14 | 2019-11-06 | Chris Marchbanks (GitHub: @csmarchbanks) |
| v2.15 | 2019-12-18 | Bartek Plotka (GitHub: @bwplotka) |
| v2.16 | 2020-01-29 | Callum Styan (GitHub: @cstyan) |
| v2.17 | 2020-03-11 | Julien Pivotto (GitHub: @roidelapluie) |
| v2.18 | 2020-04-22 | Bartek Plotka (GitHub: @bwplotka) |
| v2.19 | 2020-06-03 | Ganesh Vernekar (GitHub: @codesome) |
| v2.20 | 2020-07-15 | Björn Rabenstein (GitHub: @beorn7) |
| v2.21 | 2020-08-26 | Julien Pivotto (GitHub: @roidelapluie) |
| v2.22 | 2020-10-07 | Frederic Branczyk (GitHub: @brancz) |
| v2.23 | 2020-11-18 | Ganesh Vernekar (GitHub: @codesome) |
| v2.24 | 2020-12-30 | Björn Rabenstein (GitHub: @beorn7) |
| v2.25 | 2021-02-10 | Julien Pivotto (GitHub: @roidelapluie) |
| v2.26 | 2021-03-24 | Bartek Plotka (GitHub: @bwplotka) |
| v2.27 | 2021-05-05 | Chris Marchbanks (GitHub: @csmarchbanks) |
| v2.28 | 2021-06-16 | Julius Volz (GitHub: @juliusv) |
| v2.29 | 2021-07-28 | Frederic Branczyk (GitHub: @brancz) |
| v2.30 | 2021-09-08 | Ganesh Vernekar (GitHub: @codesome) |
| v2.31 | 2021-10-20 | Julien Pivotto (GitHub: @roidelapluie) |
| v2.32 | 2021-12-01 | Julius Volz (GitHub: @juliusv) |
| v2.33 | 2022-01-12 | Björn Rabenstein (GitHub: @beorn7) |
| v2.34 | 2022-02-23 | Chris Marchbanks (GitHub: @csmarchbanks) |
| v2.35 | 2022-04-06 | Augustin Husson (GitHub: @nexucis) |
| v2.36 | 2022-05-18 | Matthias Loibl (GitHub: @metalmatze) |
| v2.37 LTS | 2022-06-29 | Julien Pivotto (GitHub: @roidelapluie) |
| v2.38 | 2022-08-10 | Julius Volz (GitHub: @juliusv) |
| v2.39 | 2022-09-21 | Ganesh Vernekar (GitHub: @codesome) |
| v2.40 | 2022-11-02 | Ganesh Vernekar (GitHub: @codesome) |
| v2.41 | 2022-12-14 | Julien Pivotto (GitHub: @roidelapluie) |
| v2.42 | 2023-01-25 | Kemal Akkoyun (GitHub: @kakkoyun) |
| v2.43 | 2023-03-08 | Julien Pivotto (GitHub: @roidelapluie) |
| v2.44 | 2023-04-19 | Bryan Boreham (GitHub: @bboreham) |
| v2.45 LTS | 2023-05-31 | Jesus Vazquez (Github: @jesusvazquez) |
| v2.46 | 2023-07-12 | Julien Pivotto (GitHub: @roidelapluie) |
| v2.47 | 2023-08-23 | Bryan Boreham (GitHub: @bboreham) |
| v2.48 | 2023-10-04 | Levi Harrison (GitHub: @LeviHarrison) |
| v2.49 | 2023-12-05 | Bartek Plotka (GitHub: @bwplotka) |
| v2.50 | 2024-01-16 | Augustin Husson (GitHub: @nexucis) |
| v2.51 | 2024-03-07 | Bryan Boreham (GitHub: @bboreham) |
| v2.52 | 2024-04-22 | Arthur Silva Sens (GitHub: @ArthurSens) |
| v2.53 LTS | 2024-06-03 | George Krajcsovits (GitHub: @krajorama) |
| v2.54 | 2024-07-17 | Bryan Boreham (GitHub: @bboreham) |
| v2.55 | 2024-09-17 | Bryan Boreham (GitHub: @bboreham) |
| release series | date of first pre-release (year-month-day) | release shepherd |
|----------------|--------------------------------------------|-----------------------------------|
| v3.0 | 2024-11-14 | Jan Fajerski (GitHub: @jan--f) |
| v3.1 | 2024-12-17 | Bryan Boreham (GitHub: @bboreham) |
| v3.2 | 2025-01-28 | Jan Fajerski (GitHub: @jan--f) |
| v3.3 | 2025-03-11 | Ayoub Mrini (Github: @machine424) |
| v3.4 | 2025-04-22 | **volunteer welcome** |

If you are interested in volunteering please create a pull request against the [prometheus/prometheus](https://github.com/prometheus/prometheus) repository and propose yourself for the release series of your choice.

Expand Down Expand Up @@ -204,7 +158,7 @@ Then release with `git tag-release`.

Signing a tag with a GPG key is appreciated, but in case you can't add a GPG key to your Github account using the following [procedure](https://help.github.com/articles/generating-a-gpg-key/), you can replace the `-s` flag by `-a` flag of the `git tag` command to only annotate the tag without signing.

Once a tag is created, the release process through CircleCI will be triggered for this tag and Circle CI will draft the GitHub release using the `prombot` account.
Once a tag is created, the release process through Github Actions will be triggered for this tag and Github Actions will draft the GitHub release using the `prombot` account.

Finally, wait for the build step for the tag to finish. The point here is to wait for tarballs to be uploaded to the Github release and the container images to be pushed to the Docker Hub and Quay.io. Once that has happened, click _Publish release_, which will make the release publicly visible and create a GitHub notification.
**Note:** for a release candidate version ensure the _This is a pre-release_ box is checked when drafting the release in the Github UI. The CI job should take care of this but it's a good idea to double check before clicking _Publish release_.`
Expand Down
4 changes: 3 additions & 1 deletion cmd/prometheus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,12 +594,14 @@ func main() {
logger.Error(fmt.Sprintf("Error loading config (--config.file=%s)", cfg.configFile), "file", absPath, "err", err)
os.Exit(2)
}
// Get scrape configs to validate dynamically loaded scrape_config_files.
// They can change over time, but do the extra validation on startup for better experience.
if _, err := cfgFile.GetScrapeConfigs(); err != nil {
absPath, pathErr := filepath.Abs(cfg.configFile)
if pathErr != nil {
absPath = cfg.configFile
}
logger.Error(fmt.Sprintf("Error loading scrape config files from config (--config.file=%q)", cfg.configFile), "file", absPath, "err", err)
logger.Error(fmt.Sprintf("Error loading dynamic scrape config files from config (--config.file=%q)", cfg.configFile), "file", absPath, "err", err)
os.Exit(2)
}
if cfg.tsdb.EnableExemplarStorage {
Expand Down
37 changes: 22 additions & 15 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,12 @@ func Load(s string, logger *slog.Logger) (*Config, error) {
default:
return nil, fmt.Errorf("unsupported OTLP translation strategy %q", cfg.OTLPConfig.TranslationStrategy)
}

cfg.loaded = true
return cfg, nil
}

// LoadFile parses the given YAML file into a Config.
// LoadFile parses and validates the given YAML file into a read-only Config.
// Callers should never write to or shallow copy the returned Config.
func LoadFile(filename string, agentMode bool, logger *slog.Logger) (*Config, error) {
content, err := os.ReadFile(filename)
if err != nil {
Expand Down Expand Up @@ -270,9 +271,12 @@ type Config struct {
RemoteWriteConfigs []*RemoteWriteConfig `yaml:"remote_write,omitempty"`
RemoteReadConfigs []*RemoteReadConfig `yaml:"remote_read,omitempty"`
OTLPConfig OTLPConfig `yaml:"otlp,omitempty"`

loaded bool // Certain methods require configuration to use Load validation.
}

// SetDirectory joins any relative file paths with dir.
// This method writes to config, and it's not concurrency safe.
func (c *Config) SetDirectory(dir string) {
c.GlobalConfig.SetDirectory(dir)
c.AlertingConfig.SetDirectory(dir)
Expand Down Expand Up @@ -302,24 +306,26 @@ func (c Config) String() string {
return string(b)
}

// GetScrapeConfigs returns the scrape configurations.
// GetScrapeConfigs returns the read-only, validated scrape configurations including
// the ones from the scrape_config_files.
// This method does not write to config, and it's concurrency safe (the pointer receiver is for efficiency).
// This method also assumes the Config was created by Load or LoadFile function, it returns error
// if it was not. We can't re-validate or apply globals here due to races,
// read more https://github.com/prometheus/prometheus/issues/15538.
func (c *Config) GetScrapeConfigs() ([]*ScrapeConfig, error) {
scfgs := make([]*ScrapeConfig, len(c.ScrapeConfigs))
if !c.loaded {
// Programmatic error, we warn before more confusing errors would happen due to lack of the globalization.
return nil, errors.New("scrape config cannot be fetched, main config was not validated and loaded correctly; should not happen")
}

scfgs := make([]*ScrapeConfig, len(c.ScrapeConfigs))
jobNames := map[string]string{}
for i, scfg := range c.ScrapeConfigs {
// We do these checks for library users that would not call validate in
// Unmarshal.
if err := scfg.Validate(c.GlobalConfig); err != nil {
return nil, err
}

if _, ok := jobNames[scfg.JobName]; ok {
return nil, fmt.Errorf("found multiple scrape configs with job name %q", scfg.JobName)
}
jobNames[scfg.JobName] = "main config file"
scfgs[i] = scfg
}

// Re-read and validate the dynamic scrape config rules.
for _, pat := range c.ScrapeConfigFiles {
fs, err := filepath.Glob(pat)
if err != nil {
Expand Down Expand Up @@ -355,6 +361,7 @@ func (c *Config) GetScrapeConfigs() ([]*ScrapeConfig, error) {
}

// UnmarshalYAML implements the yaml.Unmarshaler interface.
// NOTE: This method should not be used outside of this package. Use Load or LoadFile instead.
func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
*c = DefaultConfig
// We want to set c to the defaults and then overwrite it with the input.
Expand Down Expand Up @@ -391,18 +398,18 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
}

// Do global overrides and validate unique names.
// Do global overrides and validation.
jobNames := map[string]struct{}{}
for _, scfg := range c.ScrapeConfigs {
if err := scfg.Validate(c.GlobalConfig); err != nil {
return err
}

if _, ok := jobNames[scfg.JobName]; ok {
return fmt.Errorf("found multiple scrape configs with job name %q", scfg.JobName)
}
jobNames[scfg.JobName] = struct{}{}
}

rwNames := map[string]struct{}{}
for _, rwcfg := range c.RemoteWriteConfigs {
if rwcfg == nil {
Expand Down
2 changes: 2 additions & 0 deletions config/config_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package config
const ruleFilesConfigFile = "testdata/rules_abs_path.good.yml"

var ruleFilesExpectedConf = &Config{
loaded: true,

GlobalConfig: DefaultGlobalConfig,
Runtime: DefaultRuntimeConfig,
RuleFiles: []string{
Expand Down
26 changes: 22 additions & 4 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const (
)

var expectedConf = &Config{
loaded: true,
GlobalConfig: GlobalConfig{
ScrapeInterval: model.Duration(15 * time.Second),
ScrapeTimeout: DefaultGlobalConfig.ScrapeTimeout,
Expand Down Expand Up @@ -1512,10 +1513,10 @@ func TestYAMLRoundtrip(t *testing.T) {
require.NoError(t, err)

out, err := yaml.Marshal(want)
require.NoError(t, err)

got, err := Load(string(out), promslog.NewNopLogger())
require.NoError(t, err)
got := &Config{}
require.NoError(t, yaml.UnmarshalStrict(out, got))

require.Equal(t, want, got)
}
Expand All @@ -1525,10 +1526,10 @@ func TestRemoteWriteRetryOnRateLimit(t *testing.T) {
require.NoError(t, err)

out, err := yaml.Marshal(want)
require.NoError(t, err)

got, err := Load(string(out), promslog.NewNopLogger())
require.NoError(t, err)
got := &Config{}
require.NoError(t, yaml.UnmarshalStrict(out, got))

require.True(t, got.RemoteWriteConfigs[0].QueueConfig.RetryOnRateLimit)
require.False(t, got.RemoteWriteConfigs[1].QueueConfig.RetryOnRateLimit)
Expand Down Expand Up @@ -2219,6 +2220,7 @@ func TestEmptyConfig(t *testing.T) {
c, err := Load("", promslog.NewNopLogger())
require.NoError(t, err)
exp := DefaultConfig
exp.loaded = true
require.Equal(t, exp, *c)
}

Expand Down Expand Up @@ -2268,6 +2270,7 @@ func TestEmptyGlobalBlock(t *testing.T) {
require.NoError(t, err)
exp := DefaultConfig
exp.Runtime = DefaultRuntimeConfig
exp.loaded = true
require.Equal(t, exp, *c)
}

Expand Down Expand Up @@ -2548,3 +2551,18 @@ func TestScrapeProtocolHeader(t *testing.T) {
})
}
}

// Regression test against https://github.com/prometheus/prometheus/issues/15538
func TestGetScrapeConfigs_Loaded(t *testing.T) {
t.Run("without load", func(t *testing.T) {
c := &Config{}
_, err := c.GetScrapeConfigs()
require.EqualError(t, err, "scrape config cannot be fetched, main config was not validated and loaded correctly; should not happen")
})
t.Run("with load", func(t *testing.T) {
c, err := Load("", promslog.NewNopLogger())
require.NoError(t, err)
_, err = c.GetScrapeConfigs()
require.NoError(t, err)
})
}
2 changes: 2 additions & 0 deletions config/config_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ package config
const ruleFilesConfigFile = "testdata/rules_abs_path_windows.good.yml"

var ruleFilesExpectedConf = &Config{
loaded: true,

GlobalConfig: DefaultGlobalConfig,
Runtime: DefaultRuntimeConfig,
RuleFiles: []string{
Expand Down
7 changes: 7 additions & 0 deletions docs/configuration/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,13 @@ http_headers:

Azure SD configurations allow retrieving scrape targets from Azure VMs.

The discovery requires at least the following permissions:

* `Microsoft.Compute/virtualMachines/read`: Required for VM discovery
* `Microsoft.Network/networkInterfaces/read`: Required for VM discovery
* `Microsoft.Compute/virtualMachineScaleSets/virtualMachines/read`: Required for scale set (VMSS) discovery
* `Microsoft.Compute/virtualMachineScaleSets/virtualMachines/networkInterfaces/read`: Required for scale set (VMSS) discovery

The following meta labels are available on targets during [relabeling](#relabel_config):

* `__meta_azure_machine_id`: the machine ID
Expand Down
Loading
Loading