License monitoring
License expiration monitoring ¶
When the license expires the IDLD Server stops functioning. You can monitor the license's expiration date with Prometheus and set up alerting, so you can request the additional license in advance.
With the Prometheus you can setup Alertmanager, which can send notifications to email, Slack, Telegram and other destinations.
Configure Prometheus¶
IDLive Doc Server provides the /metrics
endpoint for the Prometheus to scrape. One of the metrics is idlivedoc_license_remaining_days
, it's a number of days left in the active license:
# HELP idlivedoc_license_remaining_days Days before the license expiration date
# TYPE idlivedoc_license_remaining_days gauge
idlivedoc_license_remaining_days{application="IDLive Doc Server",} 29.0
When this value becomes zero, the license expires.
To scrape the metrics from the Server put these lines into your prometheus.yml
file:
scrape_configs:
- job_name: idlivedoc
scrape_interval: 1h
static_configs:
- targets: ["localhost:8080"]
This will instruct Prometheus to collect metrics every hour. You can check the current value via the Prometheus's expression browser. Navigate to http://localhost:9090 and query for the idlivedoc_license_remaining_days
metric in the "Graphs" page:
To configure alerts create this prometheus.rules.yml
file:
groups:
- name: idlivedoc
rules:
- alert: IDLiveDocLicenseIsAboutToExpire
expr: idlivedoc_license_remaining_days < 30
annotations:
summary: "License for IDLive Doc will expire in {{ $value }} days"
It instructs Prometheus to start an alert where there is only one month left before the license expiration. Put it next to prometheus.yml
, which should also be updated to pick up the rules' file:
rule_files:
- prometheus.rules.yml
Now you can see the alert in the "Alerts" page:
It will be in the "Firing" state when the license is about to expire.
prometheus.yml
alerting:
alertmanagers:
- static_configs:
- targets:
- localhost:9093
rule_files:
- prometheus.rules.yml
scrape_configs:
- job_name: idlivedoc
scrape_interval: 1h
static_configs:
- targets: ["localhost:8080"]
prometheus.rules.yml
groups:
- name: idlivedoc
rules:
- alert: IDLiveDocLicenseIsAboutToExpire
expr: idlivedoc_license_remaining_days < 30
annotations:
summary: "License for IDLive Doc will expire in {{ $value }} days"