geluk / matrix-webhook-gateway

Webhook gateway for Matrix / Synapse. Create and manage webhooks in Matrix channels for multiple services.
MIT License
18 stars 4 forks source link

Prometheus webhooks not working with prometheus.ts plugin #46

Closed Dual-0 closed 2 years ago

Dual-0 commented 2 years ago

Hello,

the prometheus.ts plugin is not working with my test alert rule send via alert manager. alert rule in prometheus:

groups:
- name: test

  rules:
  - alert: TEST ALERT FROM PROMETHEUS PLEASE ACKNOWLEDGE
    expr: prometheus_build_info{instance="localhost:9090"} == 1
    for: 10s
    labels:
      severity: warning
    annotations:
      action: TESTING PLEASE ACKNOWLEDGE, NO FURTHER ACTION REQUIRED ONLY A TEST
      description: TEST ALERT FROM {{ $labels.instance }}

matrix-webhook-gateway.service

Feb 02 23:25:13 COM node[1102626]: 2022-02-02 23:25:13.264  INFO [webhook-srv] Web server running on 0.0.0.0:8020
Feb 02 23:34:29 COM node[1102626]: 2022-02-02 23:34:29.592  ERROR [plg-prometheus] MatrixHttpClient (REQ-5)
Feb 02 23:34:29 COM node[1102626]: {
Feb 02 23:34:29 COM node[1102626]:   errcode: 'M_USER_IN_USE',
Feb 02 23:34:29 COM node[1102626]:   error: 'User ID already taken.'
Feb 02 23:34:29 COM node[1102626]: }
Feb 02 23:34:29 COM node[1102626]: 2022-02-02 23:34:29.593  ERROR [plg-prometheus] Appservice Error registering user: User ID is in use
Feb 02 23:34:29 COM node[1102626]: 2022-02-02 23:34:29.836  ERROR [webhook-srv] Failed to handle webhook invocation:
Feb 02 23:34:29 COM node[1102626]:  TypeError  Cannot read properties of undefined (reading 'formatPlain')
Feb 02 23:34:29 COM node[1102626]: error stack:
Feb 02 23:34:29 COM node[1102626]: • formatting.ts:74 toPlain
Feb 02 23:34:29 COM node[1102626]:     src/formatting/formatting.ts:74:24
Feb 02 23:34:29 COM node[1102626]: • formatting.ts:92 formatPlain
Feb 02 23:34:29 COM node[1102626]:     src/formatting/formatting.ts:92:30
Feb 02 23:34:29 COM node[1102626]: • formatting.ts:74 toPlain
Feb 02 23:34:29 COM node[1102626]:     src/formatting/formatting.ts:74:25
Feb 02 23:34:29 COM node[1102626]: • formatting.ts:361 <anonymous>
Feb 02 23:34:29 COM node[1102626]:     src/formatting/formatting.ts:361:49
Feb 02 23:34:29 COM node[1102626]: • formatting.ts:361 formatPlain
Feb 02 23:34:29 COM node[1102626]:     src/formatting/formatting.ts:361:32
Feb 02 23:34:29 COM node[1102626]: • formatting.ts:74 toPlain
Feb 02 23:34:29 COM node[1102626]:     src/formatting/formatting.ts:74:25
Feb 02 23:34:29 COM node[1102626]: • formatting.ts:92 formatPlain
Feb 02 23:34:29 COM node[1102626]:     src/formatting/formatting.ts:92:30
Feb 03 03:12:31 COM node[1102626]: 2022-02-03 03:12:31.817  ERROR [plg-prometheus] MatrixHttpClient (REQ-8)
Feb 03 03:12:31 COM node[1102626]: {
Feb 03 03:12:31 COM node[1102626]:   errcode: 'M_USER_IN_USE',
Feb 03 03:12:31 COM node[1102626]:   error: 'User ID already taken.'
Feb 03 03:12:31 COM node[1102626]: }

Is there specification for the alert rules to work with the prometheus plugin?

Dual-0 commented 2 years ago

I figure it out... the action label under annotations cause the issue.

Seems the plugin only handels the official alerting rules template and of course the webhook template. Sorry for the misunderstanding.

Anyway, hope this helps others too.

geluk commented 2 years ago

Yes, that is correct! I have updated the readme to better reflect this.