mirror of
https://github.com/simple-login/app.git
synced 2024-11-14 08:01:13 +01:00
0e82801512
* chore: add upcloud monitoring * Added db_role to new_relic metrics --------- Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
20 lines
710 B
Python
20 lines
710 B
Python
from app.config import UPCLOUD_DB_ID, UPCLOUD_PASSWORD, UPCLOUD_USERNAME
|
|
from app.log import LOG
|
|
from monitor.newrelic import NewRelicClient
|
|
from monitor.upcloud import UpcloudClient
|
|
|
|
|
|
class MetricExporter:
|
|
def __init__(self, newrelic_license: str):
|
|
self.__upcloud = UpcloudClient(
|
|
username=UPCLOUD_USERNAME, password=UPCLOUD_PASSWORD
|
|
)
|
|
self.__newrelic = NewRelicClient(newrelic_license)
|
|
|
|
def run(self):
|
|
try:
|
|
metrics = self.__upcloud.get_metrics(UPCLOUD_DB_ID)
|
|
self.__newrelic.send(metrics)
|
|
LOG.info("Upcloud metrics sent to NewRelic")
|
|
except Exception as e:
|
|
LOG.warn(f"Could not export metrics: {e}")
|