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 Grafana v9.x messages, fixes #29 #45

Merged
merged 1 commit into from
Sep 7, 2022

Conversation

svenseeberg
Copy link
Contributor

@svenseeberg svenseeberg commented Sep 7, 2022

This PR adds support for Grafana v9.x style alert messages by adding a new formatter. If the old formatter detects that the JSON was emitted by a version 9 Grafana, it automatically uses the newer formatter. Additionally, an example JSON is provided.

Much nicer instead of replacing new line characters would be parsing the JSON attributes and creating a nice formatted markdown message. That could be a feature in the future.

Fixes #29

@svenseeberg
Copy link
Contributor Author

I can see that there are some CI tests. Awesome, I will update the PR to fix the issues.

@svenseeberg svenseeberg force-pushed the bugfix/grafana-9x-formatting branch 2 times, most recently from ff3ec6a to 0439a59 Compare September 7, 2022 13:27
@codecov-commenter
Copy link

codecov-commenter commented Sep 7, 2022

Codecov Report

Merging #45 (e139c3a) into master (3288c3f) will increase coverage by 0.32%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #45      +/-   ##
==========================================
+ Coverage   93.61%   93.93%   +0.32%     
==========================================
  Files           6        6              
  Lines         188      198      +10     
==========================================
+ Hits          176      186      +10     
  Misses         12       12              
Impacted Files Coverage Δ
matrix_webhook/formatters.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@svenseeberg
Copy link
Contributor Author

@nim65s I guess that my forked repo PR does not have access to the API key in the environment?

@nim65s
Copy link
Owner

nim65s commented Sep 7, 2022

@svenseeberg the issue here is that in grafana 9x, there is a key in the JSON, and that one takes precedence over the key GET parameter. I guess we can configure grafana 9x hooks with a key, and that's exactly what matrix-webhook is looking for.

So you can remove "key": KEY from the python test file, and the associated KEY import, and instead put the right key in the json file.

This key is not a real secret configured in this github repositiory: it is ak, according to the tests/.env file. Otherwise you couldn't run the tests locally with docker-compose -f test.yml up --exit-code-from tests --force-recreate --build :)

@svenseeberg svenseeberg force-pushed the bugfix/grafana-9x-formatting branch 7 times, most recently from b32e226 to de238f9 Compare September 7, 2022 15:36
@nim65s
Copy link
Owner

nim65s commented Sep 7, 2022

Perfect, thanks !

@nim65s nim65s merged commit 8808322 into nim65s:master Sep 7, 2022
nim65s added a commit that referenced this pull request Sep 7, 2022
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.

New Grafana notifications not formatted correctly
3 participants