Monitor license expiration¶
When the license expires the IDLive Face 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 Face Server provides the /metrics
endpoint for the Prometheus to scrape. One of the metrics is idliveface_license_remaining_days
, it's a number of days left in the active license:
# HELP idliveface_license_remaining_days Days before the license expiration date
# TYPE idliveface_license_remaining_days gauge
idliveface_license_remaining_days{application="idliveface-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: idliveface
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 idliveface_license_remaining_days
metric in the "Graphs" page:
To configure alerts create this prometheus.rules.yml
file:
groups:
- name: idliveface
rules:
- alert: IDLiveFaceLicenseIsAboutToExpire
expr: idliveface_license_remaining_days < 30
annotations:
summary: "License for IDLive Face 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: idliveface
scrape_interval: 1h
static_configs:
- targets: ["localhost:8080"]
prometheus.rules.yml
groups:
- name: idliveface
rules:
- alert: IDLiveFaceLicenseIsAboutToExpire
expr: idliveface_license_remaining_days < 30
annotations:
summary: "License for IDLive Face will expire in {{ $value }} days"