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

Support configure alertmanager #148

Merged
merged 6 commits into from
Sep 23, 2020
Merged

Conversation

clyang82
Copy link
Contributor

@clyang82 clyang82 commented Sep 22, 2020

Allow to configured alertmanager in ruler and then enabling me to easily forward alerts from alertmanager:

  1. expose alertmanagersURL to be able to configure alertmanager url
  2. expose rulesConfig to be able to configure name and key
  • name: rule configmap name
  • key: rule file name

/assign @squat

Signed-off-by: clyang82 <chuyang@redhat.com>
'--alertmanagers.url=' + alertmanagerURL,
for alertmanagerURL in tr.config.alertmanagersURL
] + [
'--rule-file=/etc/thanos/rules/*.rules.yaml',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes that the key used in the configmap ends in rules.yaml, which is mysterious because it is not communicated to the user. Can we instead use the pattern of requiring a rulesFileKey in the jsonnet config and use that name instead?

Copy link
Contributor Author

@clyang82 clyang82 Sep 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great comments. Thanks @squat I would like to just use *.yaml instead, because the configmap may contain multiple files. Is that OK?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trouble is that there is no guarantee that the configmap key will even end in .yaml. The user could write a configmap where the keys are

foo: ...
bar: ...
rules: ...

each of these keys could have a valid rules file for the value, but the keys don't end in .yaml and thus this flag wouldn't work. File extensions are helpful hints and conventions but are not required.
Similarly, what if the configmap hold multiple keys that end in .yaml but only ONE of them is actually a rules file? Then the ruler would be attempting to read something it can't understand, potentially causing problems.

Signed-off-by: clyang82 <chuyang@redhat.com>
@clyang82 clyang82 requested a review from squat September 22, 2020 08:31
Signed-off-by: clyang82 <chuyang@redhat.com>
withAlertmanagers:: {
local tr = self,
config+:: {
ruleConfigMapName: error 'must provide rulesConfigMapName',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to be consistent here; it should either be rulesConfigMapName or ruleConfigMapName without the s

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgot to update the message.

Signed-off-by: clyang82 <chuyang@redhat.com>
@clyang82 clyang82 requested a review from squat September 22, 2020 10:30
Copy link
Member

@squat squat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm from my side

Cc @metalmatze

@metalmatze
Copy link
Contributor

Definitely a really good change and addition 👍
I wonder as to why we need this in the mixin for alertmanagers?

                ] + [
                  '--rule-file=/etc/thanos/rules/' + tr.config.ruleFileKey,
                ],
                volumeMounts+: [
                  { name: 'rules-config', mountPath: '/etc/thanos/rules' },
                ],

Signed-off-by: clyang82 <chuyang@redhat.com>
@clyang82 clyang82 changed the title support configure alertmanager [WIP]support configure alertmanager Sep 23, 2020
@clyang82 clyang82 changed the title [WIP]support configure alertmanager Support configure alertmanager Sep 23, 2020
Signed-off-by: clyang82 <chuyang@redhat.com>
@metalmatze
Copy link
Contributor

Perfect! 👍

@metalmatze metalmatze merged commit 66b017f into thanos-io:master Sep 23, 2020
@clyang82 clyang82 deleted the alertmanager branch September 23, 2020 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants