Skip to content

Add alert probe for Zabbix#85

Merged
bzurkowski merged 4 commits intoopenrca:masterfrom
aleksandra-galara:Zabbix_integration
Jun 12, 2020
Merged

Add alert probe for Zabbix#85
bzurkowski merged 4 commits intoopenrca:masterfrom
aleksandra-galara:Zabbix_integration

Conversation

@aleksandra-galara
Copy link
Copy Markdown
Member

It implements (#9).

Signed-off-by: Aleksandra Galara a.galara@samsung.com

It implements (openrca#9).

Signed-off-by: Aleksandra Galara <a.galara@samsung.com>
Copy link
Copy Markdown
Member

@bzurkowski bzurkowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's an elegant piece of code 💯 Added only a few purely cosmetic remarks. It was hard to catch anything else 👌 I really like it! Thanks 😉

Comment thread helm/orca/config/alerts-mapping.yaml
Comment thread helm/orca/config/alerts-mapping.yaml
Comment on lines +40 to +42
labels = {}
labels['node'] = entity['hosts'][0]['host']
return labels
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can wrap it into a one-liner 😉

Comment thread requirements.txt Outdated
python-arango # MIT
pyyaml # MIT
requests # Apache License 2.0
pyzabbix
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add license information.

Comment thread orca/topology/alerts/zabbix/upstream.py Outdated
"""Upstream proxy for Zabbix."""

def get_all(self):
return self._client.trigger.get(only_true=1,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the convention in neighbour code. it would be more consistent to place arguments in a new line, like this:

some_method_with_a_very_long_name_and_lots_of_args(
    arg1=1,
    arg2=2,
    arg3=3)

Comment thread orca/topology/alerts/zabbix/probe.py Outdated
@classmethod
def get(cls, graph):
zabbix_client = ZabbixAPI(CONFIG.probes.zabbix.url)
zabbix_client.login(CONFIG.probes.zabbix.username, CONFIG.probes.zabbix.password)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider moving the login step to the upstream class. I think this is where it belongs since the other client invocations already live there (separation of concerns). The upstream class is in charge of controlling the Zabbix client object.

Copy link
Copy Markdown
Member

@bzurkowski bzurkowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixes! 😉 I have a few more remarks. The most important is related to multiple host values in trigger payload. Please, share your opinion about how we could handle this?

Comment thread helm/orca/config/alerts-mapping.yaml
Comment thread orca/topology/alerts/zabbix/upstream.py
Comment thread orca/topology/alerts/zabbix/upstream.py Outdated
Comment on lines +15 to +17
from orca.topology import upstream
from pyzabbix import ZabbixAPI
from orca.common import config
Copy link
Copy Markdown
Member

@bzurkowski bzurkowski May 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imports should be sorted according to the following convention:

imports from the standard Python library, e.g. sys, os, json
<empty line>
imports from external libraries, e.g. pyzabbix, prometheus
<empty line>
imports from project package, i.e. orca imports

Comment thread orca/topology/alerts/zabbix/probe.py Outdated
Comment on lines +15 to +18
from orca.common import config
from orca.topology import probe, utils
from orca.topology.alerts.zabbix import extractor, upstream
from pyzabbix import ZabbixAPI
Copy link
Copy Markdown
Member

@bzurkowski bzurkowski May 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, sort the imports as described in the previous comment.

Comment thread docs/integrations/zabbix/sample-1.json
Signed-off-by: Aleksandra Galara <a.galara@samsung.com>
Copy link
Copy Markdown
Member

@bzurkowski bzurkowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aleksandra-galara Thanks for the fixes. Last one remark and it's perfect 😉

Comment thread orca/topology/alerts/zabbix/upstream.py Outdated
Comment on lines +39 to +43
properties = {}
properties['host'] = host['host']
properties['description'] = trigger['description']
properties['status'] = 'active' if trigger['value'] == '1' else 'inactive'
properties['priority'] = trigger['priority']
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to move this logic to the extractor. It is the responsibility of the extractor to determine the status based on a value and map fields for priority and description. We shouldn't mix that into the upstream class, which is just a simple abstraction around retrieving payloads from API requests.

Although this may seem counterintuitive, I suggest we reimplement the upstream class to return a "raw" structure of format:

[{"host": <host>, "trigger": <trigger>}, ...]

Then, process individual items in extractor using the extraction code above.

The <trigger> could be a dict of keys cut from the full trigger payload, limited to only those keys that are required for further extraction.

Signed-off-by: Aleksandra Galara <a.galara@samsung.com>
Copy link
Copy Markdown
Member

@bzurkowski bzurkowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! 👍 Merging... ✈️

@bzurkowski bzurkowski merged commit c202619 into openrca:master Jun 12, 2020
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.

2 participants