Skip to content
This repository was archived by the owner on Jun 6, 2024. It is now read-only.

Commit 59146fa

Browse files
authored
[alert-manager] move pai-bearer-token config field under alert-manager (#5324)
1 parent ba3aa5b commit 59146fa

File tree

9 files changed

+18
-13
lines changed

9 files changed

+18
-13
lines changed

contrib/kubespray/quick-start/services-configuration.yaml.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ authentication:
213213
# if you want to enable alert-handler actions, uncomment following lines and fill the right values.
214214
# alert-manager:
215215
# port: 9093 # optional, do not modify this if you do not want to change the port alert-manager is listening on
216+
# pai-bearer-token: 'your-application-token-for-pai-rest-server'
216217
# alert-handler: # alert-handler will only be enabled when this field is not empty
217218
# port: 9095 # optional, do not modify this if you do not want to change the port alert-handler is listening on
218219
# log-level: "info" # optional
219-
# pai-bearer-token: 'your-application-token-for-pai-rest-server'
220220
# email-configs: # email-notification will only be enabled when this field is not empty
221221
# admin-receiver: addr-of-admin-receiver@example.com
222222
# smtp-host: smtp.office365.com

deployment/quick-start/services-configuration.yaml.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ rest-server:
7373
# if you want to enable alert-handler actions, uncomment following lines and fill the right values.
7474
# alert-manager:
7575
# port: 9093 # optional, do not modify this if you do not want to change the port alert-manager is listening on
76+
# pai-bearer-token: 'your-application-token-for-pai-rest-server'
7677
# alert-handler: # alert-handler will only be enabled when this field is not empty
7778
# port: 9095 # optional, do not modify this if you do not want to change the port alert-handler is listening on
7879
# log-level: "info" # optional
79-
# pai-bearer-token: 'your-application-token-for-pai-rest-server'
8080
# email-configs: # email-notification will only be enabled when this field is not empty
8181
# admin-receiver: addr-of-admin-receiver@example.com
8282
# smtp-host: smtp.office365.com

docs/manual/cluster-admin/how-to-use-alert-system.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ The alert actions and the matching rules are realized in the `alert-manager` ser
7777
```yaml
7878
alert-manager:
7979
port: 9093 # optional, do not change this if you do not want to change the port alert-manager is listening on
80+
pai-bearer-token: 'your-application-token-for-pai-rest-server'
8081
alert-handler:
8182
port: 9095 # optional, do not change this if you do not want to change the port alert-handler is listening on
82-
pai-bearer-token: 'your-application-token-for-pai-rest-server'
8383
email-configs: # email-notification will only be enabled when this field is not empty
8484
admin-receiver: addr-of-admin-receiver@example.com
8585
smtp-host: smtp.office365.com

docs_zh_CN/manual/cluster-admin/how-to-use-alert-system.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ prometheus:
7474
```yaml
7575
alert-manager:
7676
port: 9093
77+
pai-bearer-token: 'your-application-token-for-pai-rest-server'
7778
alert-handler:
7879
port: 9095
79-
pai-bearer-token: 'your-application-token-for-pai-rest-server'
8080
email-configs:
8181
admin-receiver: addr-of-admin-receiver@example.com
8282
smtp-host: smtp.office365.com

examples/cluster-configuration/services-configuration.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ rest-server:
106106
# if you want to enable alert-handler actions, uncomment following lines and fill the right values.
107107
# alert-manager:
108108
# port: 9093 # optional, do not modify this if you do not want to change the port alert-manager is listening on
109+
# pai-bearer-token: 'your-application-token-for-pai-rest-server'
109110
# alert-handler: # alert-handler will only be enabled when this field is not empty
110111
# port: 9095 # optional, do not modify this if you do not want to change the port alert-handler is listening on
111112
# log-level: "info" # optional
112-
# pai-bearer-token: 'your-application-token-for-pai-rest-server'
113113
# email-configs: # email-notification will only be enabled when this field is not empty
114114
# admin-receiver: addr-of-admin-receiver@example.com
115115
# smtp-host: smtp.office365.com

src/alert-manager/config/alert-manager.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ you should configure `alert-manager` in your `service-configuration.yaml` like f
1717
``` yaml
1818
alert-manager:
1919
port: 9093 # optional, do not change this if you do not want to change the port alert-manager is listening on
20+
pai-bearer-token: 'your-application-token-for-pai-rest-server'
2021
alert-handler: # alert-handler will only be enabled when this field is not empty
2122
port: 9095 # optional, do not change this if you do not want to change the port alert-handler is listening on
22-
pai-bearer-token: 'your-application-token-for-pai-rest-server'
2323
email-configs: # email-notification will only be enabled when this field is not empty
2424
admin-receiver: addr-of-admin-receiver@example.com
2525
smtp-host: smtp.office365.com
@@ -54,6 +54,7 @@ After parsing, if you properly configured `email-configs` and `pai-bearer-token`
5454
``` yaml
5555
alert-manager:
5656
port: 9093
57+
pai-bearer-token: 'your-application-token-for-pai-rest-server'
5758
actions-available:
5859
- webportal-notification
5960
- cordon-nodes
@@ -65,7 +66,6 @@ alert-manager:
6566
log-level: info
6667
port: 9095
6768
configured: True
68-
pai-bearer-token: 'your-application-token-for-pai-rest-server'
6969
email-configs: # email-notification will only be enabled when this field is not empty
7070
admin-receiver: addr-of-admin-receiver@example.com
7171
smtp-host: smtp.office365.com

src/alert-manager/config/alert_manager.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,12 @@ def run(self):
6464
result["alert-handler"]["email-configs"]["templates"] = self.get_email_templates()
6565

6666
# check if `pai-bearer-token` is properly configured
67-
if result.get("alert-handler") is not None and \
67+
if result.get("pai-bearer-token") is not None:
68+
token_configured = True
69+
# legacy: to be compatible with pai version <= v1.5
70+
elif result.get("alert-handler") is not None and \
6871
result["alert-handler"].get("pai-bearer-token") is not None:
72+
result["pai-bearer-token"] = result["alert-handler"]["pai-bearer-token"]
6973
token_configured = True
7074
else:
7175
token_configured = False
@@ -83,7 +87,8 @@ def run(self):
8387
result["alert-handler"]["configured"] = False
8488

8589
if result.get("cluster-utilization") is not None and \
86-
result["cluster-utilization"].get("schedule") is not None:
90+
result["cluster-utilization"].get("schedule") is not None and \
91+
token_configured:
8792
result["cluster-utilization"]["configured"] = True
8893
else:
8994
result["cluster-utilization"]["configured"] = False

src/alert-manager/deploy/alert-manager-configmap.yaml.template

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,22 +99,22 @@ data:
9999
- url: 'http://localhost:{{ cluster_cfg["alert-manager"]["alert-handler"]["port"] }}/alert-handler/send-email-to-user/?template={{ template }}'
100100
send_resolved: false
101101
http_config:
102-
bearer_token: {{ cluster_cfg["alert-manager"]["alert-handler"]["pai-bearer-token"] }}
102+
bearer_token: {{ cluster_cfg["alert-manager"]["pai-bearer-token"] }}
103103
{% endif %}
104104

105105
{% if (receiver["actions"]["stop-jobs"] is defined) and ('stop-jobs' in cluster_cfg["alert-manager"]["actions-available"]) %}
106106
- url: 'http://localhost:{{ cluster_cfg["alert-manager"]["alert-handler"]["port"] }}/alert-handler/stop-jobs'
107107
send_resolved: false
108108
http_config:
109-
bearer_token: {{ cluster_cfg["alert-manager"]["alert-handler"]["pai-bearer-token"] }}
109+
bearer_token: {{ cluster_cfg["alert-manager"]["pai-bearer-token"] }}
110110
{% endif %}
111111

112112
{% if (receiver["actions"]["tag-jobs"] is defined) and ('tag-jobs' in cluster_cfg["alert-manager"]["actions-available"]) %}
113113
{% for tag in receiver["actions"]["tag-jobs"]["tags"] %}
114114
- url: 'http://localhost:{{ cluster_cfg["alert-manager"]["alert-handler"]["port"] }}/alert-handler/tag-jobs/{{ tag }}'
115115
send_resolved: false
116116
http_config:
117-
bearer_token: {{ cluster_cfg["alert-manager"]["alert-handler"]["pai-bearer-token"] }}
117+
bearer_token: {{ cluster_cfg["alert-manager"]["pai-bearer-token"] }}
118118
{% endfor %}
119119
{% endif %}
120120

src/alert-manager/deploy/alert-manager-cronjob.yaml.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ spec:
3838
value: "{{ cluster_cfg['pylon']['uri']}}"
3939
{%- endif %}
4040
- name: PAI_BEARER_TOKEN
41-
value: {{ cluster_cfg["alert-manager"]["alert-handler"]["pai-bearer-token"] }}
41+
value: {{ cluster_cfg["alert-manager"]["pai-bearer-token"] }}
4242
- name: PROMETHEUS_SCRAPE_INTERVAL
4343
value: "{{ cluster_cfg["prometheus"]["scrape_interval"] }}"
4444
imagePullSecrets:

0 commit comments

Comments
 (0)