Stats

/v1/stats

Collect important stats about your Coreapp and database with the stats node. Measure the performance of your queue with current queue callback size and number of pending messages.

This document covers:

Coreapp Stats

Use the /v1/stats/app endpoint to retrieve Coreapp stats in JSON format. Coreapp stats live in memory and can be queried at regular intervals if needed.

Request

GET /v1/stats/app

Response

If successful, your request returns 200 OK and a message body containing an app object.

Single instance

"stats": {
    "app": {
        "callback_queue_size": {
            "data": [
                {
                    "value": 450
                }
            ],
            "help": "Current callback queue size",
            "type": "gauge"
        },
        "callback_requests_duration_ms_count": {
            "data": [
                {
                    "labels": {
                        "result": "success",
                        "type": "inbound_message"
                    },
                    "value": 2
                },
                {
                    "labels": {
                        "result": "1",
                        "type": "status_change"
                    },
                    "value": 28
                }
            ],
            "help": "Total number of callback requests",
            "type": "counter"
        },
        "callback_requests_duration_ms_sum": {
            "data": [
                {
                    "labels": {
                        "result": "success",
                        "type": "inbound_message"
                    },
                    "value": 32
                },
                {
                    "labels": {
                        "result": "1",
                        "type": "status_change"
                    },
                    "value": 451
                }
            ],
            "help": "Total duration(ms) of callback requests",
            "type": "counter"
        },
        "db_request_duration_us_count": {
            "data": [
                {
                    "labels": {
                        "db": "messageStore",
                        "request": "commit"
                    },
                    "value": 5
                },
                {
                    "labels": {
                        "db": "_jobqueue-WhatsApp",
                        "request": "prepare"
                    },
                    "value": 10
                }, ...
            "help": "Total number of successful SQL queries",
            "type": "counter"
        },
        "db_request_duration_us_sum": {
            "data": [
                {
                    "labels": {
                        "db": "messageStore",
                        "request": "commit"
                    },
                    "value": 14967
                },
                {
                    "labels": {
                        "db": "_jobqueue-WhatsApp",
                        "request": "prepare"
                    },
                    "value": 4236
                },...
            "help": "Total duration(microseconds) of successful SQL queries",
            "type": "counter"
        },
        "endpoint_requests": {
            "data": [
                {
                    "labels": {
                        "method": "contacts",
                        "result": "ok"
                    },
                    "value": 3864
                },
                {
                    "labels": {
                        "method": "messaging",
                        "result": "ok"
                    },
                    "value": 3576
                },
                {
                    "labels": {
                        "method": "messaging",
                        "result": "1020"
                    },
                    "value": 15
                },
                {
                    "labels": {
                        "method": "control",
                        "result": "ok"
                    },
                    "value": 4169
                }
            ],
            "help": "Total number of endpoint requests made",
            "type": "counter"
        },
        "endpoint_requests_duration_ms_count": {
            "data": [
                {
                    "labels": {
                        "method": "app_stats",
                        "result": "ok"
                    },
                    "value": 1
                },
                ...
            ],
            "help": "Total number of endpoint requests",
            "type": "counter"
        },
        "endpoint_requests_duration_ms_sum": {
            "data": [
                {
                    "labels": {
                        "method": "app_stats",
                        "result": "ok"
                    },
                    "value": 2
                },
                ...
            ],
            "help": "Total duration(ms) of endpoint requests",
            "type": "counter"
        },
        "in_message_decoded": {
            "data": [
                {
                    "labels": {
                        "type": "image"
                    },
                    "value": 1
                },
                {
                    "labels": {
                        "type": "undefined"
                    },
                    "value": 8
                }
            ],
            "help": "Total number of incoming messages",
            "type": "counter"
        },
        "in_message_from_server": {
            "data": [
                {
                    "value": 9
                }
            ],
            "help": "Total number of incoming encrypted messages from server",
            "type": "counter"
        },
        "in_message_persisted": {
            "data": [
                {
                    "labels": {
                        "type": "image"
                    },
                    "value": 1
                },
                {
                    "labels": {
                        "type": "system"
                    },
                    "value": 3350
                },
                {
                    "labels": {
                        "type": "undefined"
                    },
                    "value": 8
                }
            ],
            "help": "Total number of incoming messages cached in DB",
            "type": "counter"
        },
        "in_messages_pending_processing": {
            "data": [
                {
                    "value": 0
                }
            ],
            "help": "Number of encrypted messages received yet to be processed",
            "type": "gauge"
        },
        "internal_server_conn_duration_ms_count": {
            "data": [
                {
                    "labels": {
                        "result": "Connected"
                    },
                    "value": 1
                }
            ],
            "help": "Total number of internal server connection requests made",
            "type": "counter"
        },
        "internal_server_conn_duration_ms_sum": {
            "data": [
                {
                    "labels": {
                        "result": "Connected"
                    },
                    "value": 584
                }
            ],
            "help": "Total time spent in connecting to internal server in ms",
            "type": "counter"
        },
        "internal_server_requests_duration_ms_count": {
            "data": [
                {
                    "labels": {
                        "operation": "FieldStatsResult",
                        "result": "ok"
                    },
                    "value": 2
                },
                {
                    "labels": {
                        "operation": "GetPrivacyListResult",
                        "result": "404"
                    },
                    "value": 1
                },...
            "help": "Number of internal server requests",
            "type": "counter"
        },
        "internal_server_requests_duration_ms_sum": {
            "data": [
                {
                    "labels": {
                        "operation": "FieldStatsResult",
                        "result": "ok"
                    },
                    "value": 158
                },
                {
                    "labels": {
                        "operation": "GetPrivacyListResult",
                        "result": "404"
                    },
                    "value": 347
                },...
            "help": "Duration of internal server requests",
            "type": "counter"
        },
        "media_downloads": {
            "data": [
                {
                    "labels": {
                        "result": "unknown",
                        "type": "image"
                    },
                    "value": 1
                }
            ],
            "help": "Total number of media messages downloaded from server",
            "type": "counter"
        },
        "media_uploads": {
            "data": [
                {
                    "labels": {
                        "result": "ok",
                        "type": "audio"
                    },
                    "value": 95
                },
                {
                    "labels": {
                        "result": "ok",
                        "type": "document"
                    },
                    "value": 145
                },
                {
                    "labels": {
                        "result": "ok",
                        "type": "image"
                    },
                    "value": 81
                }
            ],
            "help": "Total number of media messages uploaded to server",
            "type": "counter"
        },
        "out_message_persisted": {
            "data": [
                {
                    "labels": {
                        "type": "document"
                    },
                    "value": 145
                },
                {
                    "labels": {
                        "type": "audio"
                    },
                    "value": 95
                },
                {
                    "labels": {
                        "type": "image"
                    },
                    "value": 81
                },
                {
                    "labels": {
                        "type": "undefined"
                    },
                    "value": 79
                },
                {
                    "labels": {
                        "type": "hsm"
                    },
                    "value": 3176
                }
            ],
            "help": "Total number of outgoing messages cached in DB",
            "type": "counter"
        },
        "out_message_sent_duration_ms_count": {
            "data": [
                {
                    "labels": {
                        "retry": "0",
                        "type": "hsm"
                    },
                    "value": 3576
                }, ...
            ],
            "help": "Total number of messages sent to server successfully",
            "type": "counter"
        },
        "out_message_sent_duration_ms_sum": {
            "data": [
                {
                    "labels": {
                        "retry": "0",
                        "type": "hsm"
                    },
                    "value": 536433
                }, ...
            ],
            "help": "Total number of durations used to send messages to server",
            "type": "counter"
        },
        "out_message_status": {
            "data": [
                {
                    "labels": {
                        "status": "delivered"
                    },
                    "value": 1034
                },
                {
                    "labels": {
                        "status": "sent"
                    },
                    "value": 3576
                },
                {
                    "labels": {
                        "status": "read"
                    },
                    "value": 1034
                }
            ],
            "help": "Total number of outgoing messages of a particular status",
            "type": "counter"
        },
        "pending_callbacks": {
            "data": [
                {
                    "labels": {
                        "type": "inbound_message"
                    },
                    "value": 8
                },
                {
                    "labels": {
                        "type": "status_change"
                    },
                    "value": 442
                }
            ],
            "help": "Current number of pending callbacks in the queue",
            "type": "gauge"
        },
        "pending_messages": {
            "data": [
                {
                    "value": 0
                }
            ],
            "help": "Current number of pending messages in the queue",
            "type": "gauge"
        }
    }
}

High Availability/Multiconnect

{
    "stats": {
       "app": {
           "your-hostname1:your-container-id1":{
             "callback_queue_size": {
               "data": [
                 {"value": 450}
               ],
               "help": "Current callback queue size",
               "type": "gauge"
             },
             ...
           },
           "your-hostname2:your-container-id2":{
             "callback_queue_size": {
               "data": [
                 {"value": 10}
               ],
               "help": "Current callback queue size",
               "type": "gauge"
             },
             ...
           },
           ...
        }
    }
}

Parameters

NameTypeDescription

callback_queue_size

Object

Current callback queue size

callback_requests_duration_ms_count

Object

Total number of callback requests made and result

callback_requests_duration_ms_sum

Object

Total duration (ms) of callback requests

concurrent_rate_limit_triggered*

Object

Current number of concurrent rate limit triggers

db_request_duration_us_count

Object

Total number of successful SQL queries

db_request_duration_us_sum

Object

Total duration (microseconds) of successful SQL queries

db_request_error_duration_us_count

Object

Total number of failed SQL queries

db_request_error_duration_us_sum

Object

Total duration(microseconds) of failed SQL queries

endpoint_requests

Object

Total number of endpoint requests made for a given endpoint and result (either ok or an error code)

endpoint_requests_duration_ms_count

Object

Total number of endpoint requests

endpoint_requests_duration_ms_sum

Object

Total duration (ms) of endpoint requests

in_message_decoded*

Object

Total number of incoming messages decrypted successfully

in_message_from_server*

Object

Total number of incoming encrypted messages from server

in_message_persisted*

Object

Total number of incoming messages cached in the database

in_messages_pending_processing

Object

Number of encrypted messages received yet to be processed

internal_server_conn_duration_ms_count

Object

Total number of internal server connection requests made

internal_server_conn_duration_ms_sum

Object

Total duration (ms) spent in connecting to internal server in ms

internal_server_requests_duration_ms_count

Object

Total number of internal server requests

internal_server_requests_duration_ms_sum

Object

Total duration(ms) of internal server requests

media_downloads*

Object

Total number of media files downloaded from server

media_uploads*

Object

Total number of media files uploaded to server

out_message_persisted*

Object

Total number of outgoing messages cached in the database

out_message_status

Object

Total number of outgoing messages of a particular status

out_message_sent_duration_ms_count

Object

Total number of messages sent to server successfully

out_message_sent_duration_ms_sum

Object

Total duration (ms) used to send messages to server

pending_callbacks*

Object

Current number of pending callbacks in the queue for each callback type

pending_messages

Object

Current number of pending messages in the queue

per_sec_request_rate_limit_triggered*

Object

Current number of per second request rate limit triggers

per_hour_request_rate_limit_triggered*

Object

Current number of per hour request rate limit triggers

per_day_request_rate_limit_triggered*

Object

Current number of per day request rate limit triggers

per_day_contacts_scrape_limit_triggered*

Object

Current number of per day contact scrape limit triggers

* These response fields are available beginning with v2.21.3.

Coreapp Stats — Prometheus

Returns the Coreapp data in Prometheus format.

Request

GET /v1/stats/app?format=prometheus

Response

Single instance

# HELP callback_queue_size Current callback queue size
# TYPE callback_queue_size gauge
callback_queue_size 450
# HELP callback_requests_duration_ms_count Total number of callback requests
# TYPE callback_requests_duration_ms_count counter
callback_requests_duration_ms_count{result="success",type="inbound_message"} 2
callback_requests_duration_ms_count{result="1",type="status_change"} 28
# HELP callback_requests_duration_ms_sum Total duration(ms) of callback requests
# TYPE callback_requests_duration_ms_sum counter
callback_requests_duration_ms_sum{result="success",type="inbound_message"} 32
callback_requests_duration_ms_sum{result="1",type="status_change"} 451
# HELP db_request_duration_us_count Total number of successful SQL queries
# TYPE db_request_duration_us_count counter
db_request_duration_us_count{db="messageStore",request="commit"} 5
db_request_duration_us_count{db="_jobqueue-WhatsApp",request="prepare"} 10
...
# HELP db_request_duration_us_sum Total duration(microseconds) of successful SQL queries
# TYPE db_request_duration_us_sum counter
db_request_duration_us_sum{db="messageStore",request="commit"} 14967
db_request_duration_us_sum{db="_jobqueue-WhatsApp",request="prepare"} 4236
...
# HELP endpoint_requests Total number of endpoint requests made
# TYPE endpoint_requests counter
endpoint_requests{method="contacts",result="ok"} 3864
endpoint_requests{method="messaging",result="ok"} 3576
endpoint_requests{method="messaging",result="1020"} 15
endpoint_requests{method="control",result="ok"} 4262
# HELP endpoint_requests_duration_ms_count Total number of endpoint requests
# TYPE endpoint_requests_duration_ms_count counter
endpoint_requests_duration_ms_count{method="app_stats",result="ok"} 1
...
# HELP endpoint_requests_duration_ms_sum Total duration(ms) of endpoint requests
# TYPE endpoint_requests_duration_ms_sum counter
endpoint_requests_duration_ms_sum{method="app_stats",result="ok"} 2
...
# HELP in_message_decoded Total number of incoming messages
# TYPE in_message_decoded counter
in_message_decoded{type="image"} 1
in_message_decoded{type="undefined"} 8
# HELP in_message_from_server Total number of incoming encrypted messages from server
# TYPE in_message_from_server counter
in_message_from_server 9
# HELP in_message_persisted Total number of incoming messages cached in DB
# TYPE in_message_persisted counter
in_message_persisted{type="image"} 1
in_message_persisted{type="system"} 3350
in_message_persisted{type="undefined"} 8
# HELP in_messages_pending_processing Number of encrypted messages received yet to be processed
# TYPE in_messages_pending_processing gauge
in_messages_pending_processing 0
# HELP internal_server_conn_duration_ms_count Total number of internal server connection requests made
# TYPE internal_server_conn_duration_ms_count counter
internal_server_conn_duration_ms_count{result="Connected"} 1
# HELP internal_server_conn_duration_ms_sum Total time spent in connecting to internal server in ms
# TYPE internal_server_conn_duration_ms_sum counter
internal_server_conn_duration_ms_sum{result="Connected"} 584
# HELP internal_server_requests_duration_ms_count Number of internal server requests
# TYPE internal_server_requests_duration_ms_count counter
internal_server_requests_duration_ms_count{operation="FieldStatsResult",result="ok"} 2
internal_server_requests_duration_ms_count{operation="GetPrivacyListResult",result="404"} 1
...
# HELP internal_server_requests_duration_ms_sum Duration of internal server requests
# TYPE internal_server_requests_duration_ms_sum counter
internal_server_requests_duration_ms_sum{operation="FieldStatsResult",result="ok"} 158
internal_server_requests_duration_ms_sum{operation="GetPrivacyListResult",result="404"} 347
...
# HELP media_downloads Total number of media messages downloaded from server
# TYPE media_downloads counter
media_downloads{result="unknown",type="image"} 1
# HELP media_uploads Total number of media messages uploaded to server
# TYPE media_uploads counter
media_uploads{result="ok",type="audio"} 95
media_uploads{result="ok",type="document"} 145
media_uploads{result="ok",type="image"} 81
# HELP out_message_persisted Total number of outgoing messages cached in DB
# TYPE out_message_persisted counter
out_message_persisted{type="document"} 145
out_message_persisted{type="audio"} 95
out_message_persisted{type="image"} 81
out_message_persisted{type="undefined"} 79
out_message_persisted{type="hsm"} 3176
# HELP out_message_sent_duration_ms_count Total number of messages sent to server successfully
# TYPE out_message_sent_duration_ms_count counter
out_message_sent_duration_ms_count{retry="0",type="hsm"} 3576
...
# HELP out_message_sent_duration_ms_sum Total number of durations used to send messages to server
# TYPE out_message_sent_duration_ms_sum counter
out_message_sent_duration_ms_sum{retry="0",type="hsm"} 536433
...
# HELP out_message_status Total number of outgoing messages of a particular status
# TYPE out_message_status counter
out_message_status{status="delivered"} 1034
out_message_status{status="sent"} 3576
out_message_status{status="read"} 1034
# HELP pending_callbacks Current number of pending callbacks in the queue
# TYPE pending_callbacks gauge
pending_callbacks{type="inbound_message"} 8
pending_callbacks{type="status_change"} 442
# HELP pending_messages Current number of pending messages in the queue
# TYPE pending_messages gauge
pending_messages 0

High Availability/Multiconnect

# HELP callback_queue_size Current callback queue size
# TYPE callback_queue_size gauge
callback_queue_size{node="your-hostname1:your-container-id1"} 0
callback_queue_size{node="your-hostname2:your-container-id2"} 0
...

Database Stats

Use the /v1/stats/db endpoint to retrieve database stats in JSON format.

Checking the database stats can take a long time and affect app performance if your database is large. It is recommended polling this information only when needed.

Request

GET /v1/stats/db

Response

If successful, your request returns 200 OK and a message body containing an db object.

Single instance

{
    "stats": {
        "db": {
            "db_contacts": {
                "data": [
                    {
                        "labels": {
                            "type": "non_whatsapp_user"
                        },
                        "value": 2
                    },
                    {
                        "labels": {
                            "type": "whatsapp_user"
                        },
                        "value": 5
                    }
                ],
                "help": "Current number of contacts in DB",
                "type": "gauge"
            },
            "db_message_receipts": {
                "data": [
                    {
                        "value": 6
                    }
                ],
                "help": "Current number of message receipts in DB",
                "type": "gauge"
            },
            "db_messages": {
                "data": [
                    {
                        "labels": {
                            "type": "undefined"
                        },
                        "value": 2
                    },
                    {
                        "labels": {
                            "type": "system"
                        },
                        "value": 1
                    }
                ],
                "help": "Current number of messages in DB",
                "type": "gauge"
            },
            "db_pending_callbacks": {
                "data": [
                    {
                        "value": 0
                    }
                ],
                "help": "Current number of pending callbacks in DB",
                "type": "gauge"
            },
            "db_pending_messages": {
                "data": [
                    {
                        "value": 0
                    }
                ],
                "help": "Current number of pending messages in DB",
                "type": "gauge"
            }
        }
    },
    "meta": {
        "api_status": "stable",
        "version": "2.18.13"
    }
} 
  

High Availability/Multiconnect

Only the primary Master will return stats, others will return {}.

{
    "stats": {
       "db": {
          "your-hostname1:your-container-id1": {},
          "your-primary-master:your-container-id2": {
             "db_contacts": {
               "data": [ {
                 "labels": {
                   "type": "whatsapp_user"
                 },
                 "value": 4
               } ],
               "help": "Current number of contacts in DB",
               "type": "gauge"
             },

             "db_message_receipts": { ... },

             "db_messages": { ... },
           
             "db_pending_callbacks": { ... },
           
             "db_pending_messages": { ... }
          },
         "your-hostname3:your-container-id3": {},
         ...
       }   
    }
}

Parameters

NameTypeDescription

db_contacts

Object

Current number of contacts in the database

db_message_receipts

Object

Current number of message receipts in the database

db_messages

Object

Current number of messages in the database

db_pending_callbacks

Object

Current number of pending callbacks in the database

db_pending_messages

Object

Current number of pending messages in the database

Database Stats — Prometheus

Returns the database stats in Prometheus format.

Request

GET /v1/stats/db?format=prometheus

Response

Single instance

# HELP db_contacts Current number of contacts in DB
# TYPE db_contacts gauge
db_contacts{type="whatsapp_user"} 3
# HELP db_message_receipts Current number of message receipts in DB
# TYPE db_message_receipts gauge
db_message_receipts 0

High Availability/Multiconnect

# HELP db_contacts Current number of contacts in DB
# TYPE db_contacts gauge
db_contacts{node="your-primary-master:your-container-id", type="whatsapp_user"} 3
# HELP db_message_receipts Current number of message receipts in DB
# TYPE db_message_receipts gauge
db_message_receipts{node="your-primary-master:your-container-id"} 0