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

Hastic-exporter for Prometheus #520

Merged
merged 3 commits into from Apr 8, 2019

Conversation

Projects
None yet
3 participants
@amper43
Copy link
Contributor

amper43 commented Apr 6, 2019

fixes #519

Changes:

  • added hastic-exporter, that requests server info and returns some metrics in Prometheus format
  • added systemd service that starts exporter at 5777 port for watching for local Hastic on 8000 port

@amper43 amper43 added the monitoring label Apr 6, 2019

@amper43 amper43 self-assigned this Apr 6, 2019

@@ -0,0 +1,65 @@
#!/usr/bin/env python3
from prometheus_client import start_http_server, Metric, REGISTRY

This comment has been minimized.

Copy link
@jonyrock

jonyrock Apr 6, 2019

Contributor

you need to declare this dependency somewhere.
It might be important which version is used here

#!/usr/bin/env python3
from prometheus_client import start_http_server, Metric, REGISTRY
import json
import requests

This comment has been minimized.

Copy link
@jonyrock

jonyrock Apr 6, 2019

Contributor

this lib should be in deps too

import requests
import sys
import time
import dateutil.parser as dt

This comment has been minimized.

Copy link
@jonyrock

jonyrock Apr 6, 2019

Contributor

this one also to deps

for name, value in metrics.items():
if value is not None:
metric = Metric(name, name, 'gauge')
metric.add_sample(name, value=value, labels={'commitHash': commitHash, 'packageVersion': packageVersion})

This comment has been minimized.

Copy link
@jonyrock

jonyrock Apr 6, 2019

Contributor

{'commitHash': commitHash, 'packageVersion': packageVersion} Looks like a duplicate (see below)

if lastAlive:
lastAlive = int(dt.parse(lastAlive).timestamp()) * 1000 #ms
metric = Metric('lastAlive', 'lastAlive', 'gauge')
metric.add_sample('lastAlive', value=lastAlive, labels={'commitHash': commitHash, 'packageVersion': packageVersion})

This comment has been minimized.

Copy link
@jonyrock

jonyrock Apr 6, 2019

Contributor

duplicate

if timestamp:
timestamp = int(dt.parse(timestamp).timestamp()) * 1000 #ms
metric = Metric('timestamp', 'timestamp', 'gauge')
metric.add_sample('timestamp', value=timestamp, labels={'commitHash': commitHash, 'packageVersion': packageVersion})

This comment has been minimized.

Copy link
@jonyrock

jonyrock Apr 6, 2019

Contributor

duplicate

@rozetko

This comment has been minimized.

Copy link
Member

rozetko commented Apr 8, 2019

Maybe it would be better to name it more explicitly (e.g. prometheus-hastic-exporter)

@rozetko rozetko merged commit 0fc857d into master Apr 8, 2019

0 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details

@rozetko rozetko deleted the hastic-exporter-for-prometheus-#519 branch Apr 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.