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

Exporting metrics and check statuses to Prometheus #317

Closed
thoo opened this issue Jul 27, 2020 · 3 comments
Closed

Exporting metrics and check statuses to Prometheus #317

thoo opened this issue Jul 27, 2020 · 3 comments

Comments

@thoo
Copy link

thoo commented Jul 27, 2020

Is there a way to push metrics and statuses to Prometheus so that I can also visualize on Grafana?
Thanks.

@yisraelU
Copy link

you can push data via a webhook upon success or failure, you would need a proxy software to convert that to the format prometheus uses

@jhuckaby
Copy link
Owner

Although not documented, Cronicle does have an HTTP REST API for fetching metrics about all completed jobs in JSON format. I have no idea what data format Prometheus / Grafana use, but you could possibly use this as a starting point, and write a converter script or something. The URI endpoint is:

http://YOUR_SERVER:3012/api/app/get_history?api_key=YOUR_API_KEY&offset=0&limit=100

Make sure you create an API Key first, then use that in the URL above where it says YOUR_API_KEY. The offset and limit params are integers used for pagination through the timeline data (higher numbers go further back in time), so you can (and should) only fetch 100 or so records (completed jobs) at a time.

Example JSON response:

{
    "code": 0,
    "rows": [
        {
            "id": "jkd6rar2iog",
            "code": 0,
            "event": "ek0bnmr96hm",
            "category": "general",
            "plugin": "urlplug",
            "hostname": "mini.local",
            "time_start": 1595990100.618,
            "elapsed": 0.3429999351501465,
            "perf": {
                "scale": 1000,
                "perf": {
                    "total": 227.237,
                    "dns": 68.96,
                    "connect": 24.828,
                    "send": 52.286,
                    "wait": 73.618,
                    "receive": 1.224,
                    "decompress": 2.509
                },
                "counters": {
                    "bytes_sent": 154,
                    "bytes_received": 443
                }
            },
            "cpu": {},
            "mem": {},
            "log_file_size": 994,
            "action": "job_complete",
            "epoch": 1595990100,
            "event_title": "EMR Auto-Upload",
            "category_title": "General",
            "plugin_title": "HTTP Request"
        },
        {
            "id": "jkd6r4buzof",
            "code": 0,
            "event": "ejs9m57bw01",
            "category": "general",
            "plugin": "urlplug",
            "hostname": "mini.local",
            "time_start": 1595989800.971,
            "elapsed": 0.5130000114440918,
            "perf": {
                "scale": 1000,
                "perf": {
                    "total": 397.582,
                    "dns": 69.316,
                    "connect": 25.463,
                    "send": 53.506,
                    "wait": 241.533,
                    "receive": 1.244,
                    "decompress": 2.54
                },
                "counters": {
                    "bytes_sent": 172,
                    "bytes_received": 567
                }
            },
            "cpu": {},
            "mem": {},
            "log_file_size": 1150,
            "action": "job_complete",
            "epoch": 1595989801,
            "event_title": "AMR Auto-Upload",
            "category_title": "General",
            "plugin_title": "HTTP Request"
        },
        ...
]

Each item in the rows array is a completed job event, and contains lots of useful information you can graph. The code represents the exit status (0 means success, any other value means an error occurred). The perf object contains the performance metrics for the job, all in milliseconds. If the jobs lasted more than 10 seconds, you will also have the CPU and memory utilization data in the cpu and mem objects, respectively.

Good luck!

@thoo
Copy link
Author

thoo commented Jul 29, 2020

Thanks. That is what I am looking for.

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

No branches or pull requests

3 participants