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

Prometheus Alertmanager for delfin #429

Closed
wants to merge 0 commits into from

Conversation

PravinRanjan10
Copy link
Contributor

What this PR does / why we need it:
It enables alerts to push prometheus alert manager
snmp2
snmp3

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:

@codecov
Copy link

codecov bot commented Dec 16, 2020

Codecov Report

Merging #429 (13960a8) into master (a59f2bc) will increase coverage by 0.02%.
The diff coverage is 33.33%.

@@            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              
Impacted Files Coverage Δ
delfin/exporter/base_exporter.py 66.03% <0.00%> (+7.57%) ⬆️
delfin/exporter/prometheus.py 30.30% <38.46%> (+5.30%) ⬆️

@@ -56,17 +53,23 @@ def __init__(self, namespace):
self.exporters = self._get_exporters()

def dispatch(self, ctxt, data):
if not isinstance(data, (list, tuple)):
Copy link
Member

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

# err_msg = six.text_type(e)
# LOG.exception(err_msg)

prometheus_alert_obj = prometheus.PrometheusAlertExporter()
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 handle exporteres dynamicllay by reading the entry point..

@@ -13,6 +13,7 @@
# limitations under the License.


import requests
Copy link
Member

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 ?

dict["annotations"]["summary"] = data.get("description")

self.alerts.append(dict)
requests.post('http://localhost:9093/api/v1/alerts', json=self.alerts)
Copy link
Member

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.

'location', 'recovery_advice', 'storage_id', 'storage_name',
'vendor', 'model', 'serial_number']

def push_prometheus_alert(self, data):
Copy link
Member

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.

@@ -73,8 +73,8 @@ class PrometheusAlertExporter(object):

alerts = []
model_key = ['alert_id', 'alert_name', 'category', 'severity', 'type',
Copy link
Collaborator

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

'location', 'recovery_advice', 'storage_id', 'storage_name',
'vendor', 'model', 'serial_number']

def push_prometheus_alert(self, data):
Copy link
Collaborator

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

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