mtakaki / cachet-url-monitor

URL monitor plugin for cachethq.io
MIT License
125 stars 49 forks source link

Metrics not pushed #86

Closed jdfranel closed 4 years ago

jdfranel commented 4 years ago

Hi @mtakaki,

First of all, thanks for this great piece of code.

I'm a pretty new user of cachet and cachet-url-monitor. So far, I have managed to configure the different components and the status is updated correctly. My problem is that I cannot see any metrics pushed but I cannot see what I am doing wrong.

I am running cachet-url-monitor in the provided Docker Container.

Here is my config:

endpoints:
  - name: _NAME_
    url: https://_URL_TO_MONITOR_/
    method: GET
    timeout: 1 # seconds
    expectation:
      - type: HTTP_STATUS
        status_range: 200
      - type: LATENCY
        threshold: 1 # seconds
      - type: REGEX
        regex: ".*<body>.*"
    allowed_fails: 0
    component_id: 25
    metric_id: 25
    action:
      - UPDATE_STATUS
      - PUSH_METRICS
    public_incidents: true
    latency_unit: ms
    frequency: 60 # seconds
cachet:
  api_url: https://_MY_CACHET_INSTANCE_/api/v1
  token: _TOKEN_

An extract of the log (seems to me that I should have some "Metric uploaded" logs between the "No changes")

     INFO [2020-03-22 13:46:03,296] cachet_url_monitor.configuration.Configuration._NAME_ - Current configuration:
cachet:
  api_url: https://_MY_CACHET_INSTANCE_/api/v1
endpoints:
  action:
  - UPDATE_STATUS
  - PUSH_METRICS
  allowed_fails: 0
  component_id: 25
  expectation:
  - status_range: 200
    type: HTTP_STATUS
  - threshold: 1
    type: LATENCY
  - regex: .*<body>.*
    type: REGEX
  frequency: 60
  latency_unit: ms
  method: GET
  metric_id: 25
  name: _NAME_
  public_incidents: true
  timeout: 1
  url: https://_URL_TO_MONITOR_/

     INFO [2020-03-22 13:46:03,491] cachet_url_monitor.configuration.Configuration._NAME_ - Component current status: ComponentStatus.OPERATIONAL
     INFO [2020-03-22 13:46:03,491] cachet_url_monitor.configuration.Configuration._NAME_ - Monitoring URL: GET https://_URL_TO_MONITOR_/
     INFO [2020-03-22 13:46:03,491] cachet_url_monitor.configuration.Configuration._NAME_ - Registered expectation: 'HTTP status range: [200, 201['
     INFO [2020-03-22 13:46:03,492] cachet_url_monitor.configuration.Configuration._NAME_ - Registered expectation: 'Latency threshold: 1.0000 seconds'
     INFO [2020-03-22 13:46:03,492] cachet_url_monitor.configuration.Configuration._NAME_ - Registered expectation: 'Regex: .*<body>.*'
     INFO [2020-03-22 13:46:03,492] cachet_url_monitor.scheduler - Registering action UPDATE_STATUS
     INFO [2020-03-22 13:46:03,492] cachet_url_monitor.scheduler - Registering action PUSH_METRICS
     INFO [2020-03-22 13:46:03,492] cachet_url_monitor.scheduler.Scheduler - Starting monitor agent...
     INFO [2020-03-22 13:47:03,666] cachet_url_monitor.configuration.Configuration._NAME_ - No changes to component status.
     INFO [2020-03-22 13:48:03,795] cachet_url_monitor.configuration.Configuration._NAME_ - No changes to component status.
     INFO [2020-03-22 13:49:03,936] cachet_url_monitor.configuration.Configuration._NAME_ - No changes to component status.
     INFO [2020-03-22 13:50:04,058] cachet_url_monitor.configuration.Configuration._NAME_ - No changes to component status.

I configured the metric in Cachet like so:

And nothing is visible on the dashbord and there is no metrics_points in cachet database (not access logs on metrics endpoints in cachet).

I have tried to tweak the monitored url and managed to get a status change by HTTP_STATUS and LATENCY, neither seems to trigger a metric push.

Any insight will be greatly appreciated.

Thanks,

analytically commented 4 years ago

@mtakaki seeing this as well

mtakaki commented 4 years ago

I'll take a look into this. It looks like if the status doesn't change, it's not triggering a metrics push. Lemme try reproduce it through unit test.

analytically commented 4 years ago

Also, UPDATE_STATUS should also run if the status doesn't change, so the date/time in the UI reflects when it was last 'Operational'?

analytically commented 4 years ago

@mtakaki did you manage to have a look?

nijel commented 4 years ago

I hit this issue too and https://github.com/mtakaki/cachet-url-monitor/pull/88 fixes it for me.

mtakaki commented 4 years ago

I'm sorry about the delay to look into it. I haven't had enough time to work on it. But I promise I'll confirm if things are looking good today.

analytically commented 4 years ago

Many thanks @mtakaki !

mtakaki commented 4 years ago

All thanks to @nijel! He's the one that fixed it, @analytically :)