-
Notifications
You must be signed in to change notification settings - Fork 355
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
Prometheus Alertmanager for delfin #429
Conversation
Codecov Report
@@ Coverage Diff @@
## master #429 +/- ##
==========================================
+ Coverage 66.24% 66.26% +0.02%
==========================================
Files 95 95
Lines 6355 6356 +1
Branches 725 723 -2
==========================================
+ Hits 4210 4212 +2
+ Misses 1934 1933 -1
Partials 211 211
|
delfin/exporter/base_exporter.py
Outdated
@@ -56,17 +53,23 @@ def __init__(self, namespace): | |||
self.exporters = self._get_exporters() | |||
|
|||
def dispatch(self, ctxt, data): | |||
if not isinstance(data, (list, tuple)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hope this can't be removed. We need to pick the exporters form entry point
delfin/exporter/base_exporter.py
Outdated
# err_msg = six.text_type(e) | ||
# LOG.exception(err_msg) | ||
|
||
prometheus_alert_obj = prometheus.PrometheusAlertExporter() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to handle exporteres dynamicllay by reading the entry point..
delfin/exporter/prometheus.py
Outdated
@@ -13,6 +13,7 @@ | |||
# limitations under the License. | |||
|
|||
|
|||
import requests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we need this in requirements list ?
delfin/exporter/prometheus.py
Outdated
dict["annotations"]["summary"] = data.get("description") | ||
|
||
self.alerts.append(dict) | ||
requests.post('http://localhost:9093/api/v1/alerts', json=self.alerts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
read alert manger host and port from config.
delfin/exporter/prometheus.py
Outdated
'location', 'recovery_advice', 'storage_id', 'storage_name', | ||
'vendor', 'model', 'serial_number'] | ||
|
||
def push_prometheus_alert(self, data): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add UTs for the new methods.
delfin/exporter/prometheus.py
Outdated
@@ -73,8 +73,8 @@ class PrometheusAlertExporter(object): | |||
|
|||
alerts = [] | |||
model_key = ['alert_id', 'alert_name', 'category', 'severity', 'type', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls use all the model fields such as occur_time
delfin/exporter/prometheus.py
Outdated
'location', 'recovery_advice', 'storage_id', 'storage_name', | ||
'vendor', 'model', 'serial_number'] | ||
|
||
def push_prometheus_alert(self, data): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data is expected to be a list of alerts to be exported
13960a8
to
e1f1934
Compare
What this PR does / why we need it:
It enables alerts to push prometheus alert manager
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes #Special notes for your reviewer:
Release note: