We are sunsetting On-Premises API. Refer to our On-Premises API Sunset document for details, and to learn how to migrate to our next-generation Cloud API.

We are making changes to the WhatsApp Business Platform pricing model. See Pricing Updates on the WhatsApp Business Platform.

Metrics

/metrics

Use the metrics node to collect important data about your website such as number of processes and outgoing traffic.

Before You Start

The metrics node supports Bearer token and API key authentication.

API Keys

If you wish to monitor the health, metrics, and stats nodes from an orchestrator, Bearer tokens are not the best option for ongoing checks as they expire every 7 days. To mediate this, you can use an API key, which can be set using the WA_API_KEY environment variable in the waweb environment section in the .yml file of your installation setup.
services:
...
  waweb:
  ...
    environment:
    ...
    WA_API_KEY: your-api-key-token
The API key you set must have a minimum of 12 characters and a maximum of 128 characters. The Webapp must be restarted whenever you change the API key.

Retrieving

Make a GET request to this edge to get website data in JSON or Prometheus format.

Example

JSON Format

GET /metrics
{
  Authorization: Bearer your-auth-token | Apikey your-api-key-token
}

As an example, the response might look like this:

{
    "metrics": {
        "web_uptime": {
            "type": "gauge",
            "help": "Number of seconds since web server has started",
            "data": [
                {
                    "labels": {
                        "node": "06475793be9d"
                    },
                    "value": 348842
                }
            ]
        },
        ...
        "web_requests": {
            "type": "gauge",
            "help": "Number of ongoing requests",
            "data": [
                {
                    "labels": {
                        "node": "06475793be9d",
                        "state": "read"
                    },
                    "value": 1
                },
                {
                    "labels": {
                        "node": "06475793be9d",
                        "state": "handle-request"
                    },
                    "value": 2
                },
            ]
        },
        "api_requests_duration_ms_sum": {
            "type": "counter",
            "help": "Total number of durations of API requests",
            "data": [
                {
                    "labels": {
                        "node": "06475793be9d",
                        "result": "200",
                        "method": "GET_v1_groups"
                    },
                    "value": 753
                },
                {
                    "labels": {
                        "node": "06475793be9d",
                        "result": "200",
                        "method": "POST_v1_settings_backup"
                    },
                    "value": 1255
                },
                {
                    "labels": {
                        "node": "06475793be9d",
                        "result": "200",
                        "method": "PATCH_v1_settings_application"
                    },
                    "value": 491
                },
                ...
            ]
        },
        ...
        "api_requests_db_duration_ms_sum": {
            "type": "counter",
            "help": "Total time spent in making DB calls",
            "data": [
                {
                    "labels": {
                        "node": "06475793be9d",
                        "query": "connect",
                        "result": "ok",
                        "method": "POST_v1_users_login"
                    },
                    "value": 0
                },
                {
                    "labels": {
                        "node": "06475793be9d",
                        "query": "executeQuery",
                        "result": "ok",
                        "method": "GET_v1_groups"
                    },
                    "value": 16
                },
                {
                    "labels": {
                        "node": "06475793be9d",
                        "query": "connect",
                        "result": "ok",
                        "method": "POST_v1_media"
                    },
                    "value": 3
                },
                ...
            ]
        },
        ...
        "api_requests_coreapp_duration_ms_sum": {
            "type": "counter",
            "help": "Total time spent in making CoreApp calls",
            "data": [
                {
                    "labels": {
                        "node": "06475793be9d",
                        "coreapp": "wacore:6252",
                        "result": "ok",
                        "method": "GET_v1_stats_db"
                    },
                    "value": 2934
                },
                {
                    "labels": {
                        "node": "06475793be9d",
                        "coreapp": "wacore:6252",
                        "result": "ok",
                        "method": "GET_v1_health"
                    },
                    "value": 2083
                },
                {
                    "labels": {
                        "node": "06475793be9d",
                        "coreapp": "wacore:6252",
                        "result": "ok",
                        "method": "PATCH_v1_settings_application"
                    },
                    "value": 328
                },
                ...
            ]
        },
        ...
    "meta": {
        "version": "v2.21.1",
        "api_status": "stable"
    }
}

Prometheus Format

The following request returns the website data in Prometheus format.

GET /metrics?format=prometheus

As an example, the response might look like this:

# HELP web_uptime Number of seconds since web server has started
# TYPE web_uptime gauge
web_uptime{node="06475793be9d"} 349141
# HELP web_connections Total number of connections accepted
# TYPE web_connections counter
web_connections{node="06475793be9d"} 23933
# HELP web_pending_connections Current number of pending connections in the queue
# TYPE web_pending_connections gauge
web_pending_connections{node="06475793be9d"} 0
# HELP web_max_pending_connections Maximum number of pending connections in the queue
# TYPE web_max_pending_connections gauge
web_max_pending_connections{node="06475793be9d"} 10
# HELP web_queue_len Size of queue for pending connections
# TYPE web_queue_len gauge
web_queue_len{node="06475793be9d"} 128
# HELP web_idle_processes Current number of idle processes
# TYPE web_idle_processes gauge
web_idle_processes{node="06475793be9d"} 10
# HELP web_total_processes Total process limit
# TYPE web_total_processes gauge
web_total_processes{node="06475793be9d"} 12
# HELP web_process_limit_hit Total number of times reached process limit
# TYPE web_process_limit_hit counter
web_process_limit_hit{node="06475793be9d"} 0
# HELP web_handled_requests Total number of requests handled
# TYPE web_handled_requests counter
web_handled_requests{node="06475793be9d"} 30054
# HELP web_out_kbytes Total outgoing traffic in kbytes
# TYPE web_out_kbytes counter
web_out_kbytes{node="06475793be9d"} 116726
# HELP web_requests Number of ongoing requests
# TYPE web_requests gauge
web_requests{node="06475793be9d",state="read"} 1
web_requests{node="06475793be9d",state="handle-request"} 2
web_requests{node="06475793be9d",state="idle"} 125
# HELP api_requests_duration_ms_sum Total number of durations of API requests
# TYPE api_requests_duration_ms_sum counter
api_requests_duration_ms_sum{node="06475793be9d",result="200",method="GET_v1_groups"} 753
api_requests_duration_ms_sum{node="06475793be9d",result="200",method="POST_v1_settings_backup"} 1255
api_requests_duration_ms_sum{node="06475793be9d",result="200",method="GET_metrics"} 249121
...
# HELP api_requests_duration_ms_count Total number of API requests
# TYPE api_requests_duration_ms_count counter
api_requests_duration_ms_count{node="06475793be9d",result="401",method="GET_v1_settings_application"} 30
api_requests_duration_ms_count{node="06475793be9d",result="200",method="GET_metrics"} 5998
api_requests_duration_ms_count{node="06475793be9d",result="404",method="POST_v1_users_login"} 1
...
# HELP api_requests_db_duration_ms_sum Total time spent in making DB calls
# TYPE api_requests_db_duration_ms_sum counter
api_requests_db_duration_ms_sum{node="06475793be9d",query="connect",result="ok",method="POST_v1_users_login"} 0
api_requests_db_duration_ms_sum{node="06475793be9d",query="executeQuery",result="ok",method="GET_v1_groups"} 16
api_requests_db_duration_ms_sum{node="06475793be9d",query="connect",result="ok",method="POST_v1_media"} 3
...
# HELP api_requests_db_duration_ms_count Total number of calls to the DB
# TYPE api_requests_db_duration_ms_count counter
api_requests_db_duration_ms_count{node="06475793be9d",query="connect",result="ok",method="GET_v1_stats_db"} 548
api_requests_db_duration_ms_count{node="06475793be9d",query="executeUpdate",result="ok",method="POST_v1_users_login"} 51
api_requests_db_duration_ms_count{node="06475793be9d",query="connect",result="ok",method="PATCH_v1_settings_application"} 38
...
# HELP api_requests_coreapp_duration_ms_sum Total time spent in making CoreApp calls
# TYPE api_requests_coreapp_duration_ms_sum counter
api_requests_coreapp_duration_ms_sum{node="06475793be9d",coreapp="wacore:6252",result="ok",method="GET_v1_stats_db"} 2934
api_requests_coreapp_duration_ms_sum{node="06475793be9d",coreapp="wacore:6252",result="ok",method="GET_v1_health"} 2090
api_requests_coreapp_duration_ms_sum{node="06475793be9d",coreapp="wacore:6252",result="ok",method="PATCH_v1_settings_application"} 328
...
# HELP api_requests_coreapp_duration_ms_count Total number of calls to the CoreApp
# TYPE api_requests_coreapp_duration_ms_count counter
api_requests_coreapp_duration_ms_count{node="06475793be9d",coreapp="wacore:6252",result="ok",method="GET_v1_stats_db"} 274
api_requests_coreapp_duration_ms_count{node="06475793be9d",coreapp="wacore:6252",result="ok",method="POST_v1_settings_backup"} 14
api_requests_coreapp_duration_ms_count{node="06475793be9d",coreapp="wacore:6252",result="ok",method="GET_v1_settings_application"} 4
...

Returned Fields

NameDescription

web_uptime

An object containing the number of seconds since the web server was started.

web_connections

An object containing the total number of connections accepted.

web_pending_connections

An object containing the current number of pending connections in the queue.

web_max_pending_connections

An object containing the maximum number of pending connections in the queue.

web_queue_len

An object containing the size of the queue for pending connections.

web_idle_processes

An object containing the current number of idle processes.

web_total_processes

An object containing the total process limit.

web_process_limit_hit

An object containing the total number of times reached process limit.

web_handled_requests

An object containing the total number of requests handled.

web_out_kbytes

An object containing the total outgoing traffic in kbytes.

web_requests

An object containing the number of ongoing requests at different state.

api_requests_duration_ms_sum

An object containing the total number of durations of API requests.

api_requests_duration_ms_count

An object containing the total number of API requests.

api_requests_db_duration_ms_sum

An object containing the total time spent in making database calls for each API.

api_requests_db_duration_ms_count

An object containing the total number of calls to the database for each API.

api_requests_coreapp_duration_ms_sum

An object containing the total time spent in making CoreApp calls for each API.

api_requests_coreapp_duration_ms_count

An object containing the total number of calls to the CoreApp for each API.