Skip to content

License monitoring

License expiration monitoring

When the license expires the IDVoice 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

IDVoice Server provides the /metrics endpoint for the Prometheus to scrape. One of the metrics is idvoice_license_remaining_days, it's a number of days left in the active license:

# HELP idvoice_license_remaining_days Days before the license expiration date
# TYPE idvoice_license_remaining_days gauge
idvoice_license_remaining_days{application="VoiceSDK 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: idvoice
    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 idvoice_license_remaining_days metric in the "Graphs" page:

Prometheus query

To configure alerts create this prometheus.rules.yml file:

groups:
  - name: idvoice
    rules:
      - alert: IDVoiceLicenseIsAboutToExpire
        expr: idvoice_license_remaining_days < 30
        annotations:
          summary: "License for IDVoice 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:

Prometheus alert

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: idvoice
    scrape_interval: 1h
    static_configs:
      - targets: ["localhost:8080"]

Download

prometheus.rules.yml
groups:
  - name: idvoice
    rules:
      - alert: IDVoiceLicenseIsAboutToExpire
        expr: idvoice_license_remaining_days < 30
        annotations:
          summary: "License for IDVoice will expire in {{ $value }} days"

Download

License expiration countdown warning

Once the license bundled with the Docker image is close to its expiration date, the server starts logging warnings on each API request, like this:

2023-07-25T14:22:13.442Z  INFO 70535 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2023-07-25T14:22:13.453Z  INFO 70535 --- [           main] net.idrnd.voicesdk.server.Application    : Started Application in 8.125 seconds (process running for 8.52)
2023-07-25T14:22:13.941Z  INFO 70535 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-07-25T14:22:13.941Z  INFO 70535 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2023-07-25T14:22:13.942Z  INFO 70535 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
2023-07-25T14:22:13.966Z  WARN 70535 --- [nio-8080-exec-1] i.v.s.w.LicenseWarningRequestInterceptor : THE LICENSE EXPIRES IN 59 DAYS (ON 2023-09-23)

By default, the countdown period starts 30 days before the license expiration date. You can override the period duration using the IDVOICE_SERVER_LICENSE_EXPIRATION_COUNTDOWN_DAYS environment variable.