-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(promtail): validate scrape_config job name, do not allow duplicat…
…e job names (#13719) Signed-off-by: François Gouteroux <[email protected]>
- Loading branch information
1 parent
45b8719
commit f2d3499
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,12 +47,47 @@ clients: | |
name: value | ||
` | ||
|
||
const testDuplicateJobsName = ` | ||
clients: | ||
- external_labels: | ||
cluster: dev1 | ||
url: https://1:[email protected]/loki/api/v1/push | ||
- external_labels: | ||
cluster: prod1 | ||
url: https://1:[email protected]/loki/api/v1/push | ||
scrape_configs: | ||
- job_name: kubernetes-pods-name | ||
kubernetes_sd_configs: | ||
- role: pod | ||
- job_name: system | ||
static_configs: | ||
- targets: | ||
- localhost | ||
labels: | ||
job: varlogs | ||
- job_name: system | ||
static_configs: | ||
- targets: | ||
- localhost | ||
labels: | ||
job: varlogs2 | ||
limits_config: | ||
readline_rate: 100 | ||
readline_burst: 200 | ||
` | ||
|
||
func Test_Load(t *testing.T) { | ||
var dst Config | ||
err := yaml.Unmarshal([]byte(testFile), &dst) | ||
require.Nil(t, err) | ||
} | ||
|
||
func Test_Load_DuplicateJobsName(t *testing.T) { | ||
var dst Config | ||
err := yaml.Unmarshal([]byte(testDuplicateJobsName), &dst) | ||
require.ErrorContains(t, err, `found multiple scrape configs with job name "system"`) | ||
} | ||
|
||
func TestHeadersConfigLoad(t *testing.T) { | ||
var dst Config | ||
err := yaml.Unmarshal([]byte(headersTestFile), &dst) | ||
|