Categorygithub.com/voipgrid/opensips_exporter
repositorypackage
1.1.1
Repository: https://github.com/voipgrid/opensips_exporter.git
Documentation: pkg.go.dev

# README

opensips_exporter

This exporter exposes OpenSIPS metrics for consumption by Prometheus using the Unix socket provided by OpenSIPS. It uses the OpenSIPS Management Interface to gather these statistics.

Tested and developed against OpenSIPS versions 1.10 and 2.4, though this will probably work with all other versions as well.

Status

Go Report Card Docker Pulls

Active / maintained

This project is considered stable for use in production environments.

Examples and dashboard

A few examples are provided to give you a clue on how this would be setup on a Prometheus instance:

And because gathering the metrics is only half of the story there's a dashboard you can import into a Grafana installation which works wonders with this exporter. The dashboard is also available on the Grafana dashboard site.

A picture is worth a thousand words. OpenSIPS Dashboard for Grafana Note: the dashboard uses elements from the node exporter but can still be used without it.

Usage

Make sure $GOPATH/bin is in your $PATH.

Usage of opensips_exporter:
  -path string
        The path where metrics will be served (default "/metrics")
  -addr string
        Address on which the OpenSIPS exporter listens. (e.g. 127.0.0.1:9434) (default ":9434")
  -socket string
        Path to the socket file for OpenSIPS. (default "/var/run/ser-fg/ser.sock")

Exported Metrics

MetricMeaningLabelsMetric type
opensips_upWhether the opensips exporter could read metrics from the Management Interface socket. (i.e. is OpenSIPS up)Gauge
opensips_core_bad_URIs_rcvdNumber of URIs that OpenSIPS failed to parse.Counter
opensips_core_bad_msg_hdrNumber of SIP headers that OpenSIPS failed to parse.Counter
opensips_core_repliesNumber of received replies by OpenSIPS.kindCounter
opensips_core_replies_totalTotal number of received replies by OpenSIPS.Counter
opensips_core_requestNumber of requests by OpenSIPS.kindCounter
opensips_core_requests_totalTotal number of received requests by OpenSIPS.Counter
opensips_core_unsupported_methodsNumber of non-standard methods encountered by OpenSIPS while parsing SIP methods.Counter
opensips_core_uptime_secondsNumber of seconds elapsed from OpenSIPS starting.Counter
opensips_dialog_dialogsNumber of dialogs.statusGauge
opensips_dialog_receivedThe number of dialog events received from other OpenSIPS instances.eventCounter
opensips_dialog_sentNumber of replicated dialog requests send to other OpenSIPS instances.eventCounter
opensips_load_loadPercentage of UDP children that are awake and processing SIP messages on the specific UDP interface.ip, port, protocolGauge
opensips_load_processThe realtime load of the process ID. (OpenSIPS >= 2.4)processGauge
opensips_load_tcp_loadPercentage of TCP children that are awake and processing SIP messages.Gauge
opensips_load_coreThe realtime load of entire OpenSIPS - this counts all the core processes of OpenSIPS; the additional processes requested by modules are not counted in this load. (OpenSIPS >= 2.4)Gauge
opensips_load_core_1mThe last minute average load of core OpenSIPS (covering only core/SIP processes) (OpenSIPS >= 2.4)Gauge
opensips_load_core_10mThe last 10 minute average load of core OpenSIPS (covering only core/SIP processes) (OpenSIPS >= 2.4)Gauge
opensips_load_allThe realtime load of entire OpenSIPS, counting both core and module processes. (OpenSIPS >= 2.4)Gauge
opensips_load_all_1mThe last minute average load of entire OpenSIPS (covering all processes). (OpenSIPS >= 2.4)Gauge
opensips_load_all_10mThe last 10 minute average load of entire OpenSIPS (covering all processes). (OpenSIPS >= 2.4)Gauge
opensips_load_1mThe last minute average load of the process ID. (OpenSIPS >= 2.4)ip, port, protocol, processGauge
opensips_load_10mThe last 10 minute average load of the process ID. (OpenSIPS >= 2.4)ip, port, protocol, processGauge
opensips_net_waitingNumber of bytes waiting to be consumed on an interface that OpenSIPS is listening on.protocolGauge
opensips_pkmem_fragmentsCurrently available number of free fragments in the private memory for OpenSIPS process.pidGauge
opensips_pkmem_free_sizeFree private memory available for the OpenSIPS process. Computed as total_size - real_used_size.pidGauge
opensips_pkmem_max_used_sizeThe maximum amount of private memory ever used by the OpenSIPS process.pidGauge
opensips_pkmem_real_used_sizeAmount of private memory requested by the OpenSIPS process, including allocator-specific metadata.pidGauge
opensips_pkmem_total_sizeTotal size of private memory available to the OpenSIPS process.pidGauge
opensips_pkmem_used_sizeAmount of private memory requested and used by the OpenSIPS process.pidGauge
opensips_registrar_default_expireValue of default_expire parameter.Gauge
opensips_registrar_max_contactsValue of max_contacts parameter.Gauge
opensips_registrar_max_expiresValue of max_expires parameter.Gauge
opensips_registrar_registrationsNumber of registrations.typeCounter
opensips_shmem_fragmentsTotal number of fragments in the shared memory.Gauge
opensips_shmem_free_sizeFree memory available. Computed as total_size - real_used_sizeGauge
opensips_shmem_max_used_sizeMaximum amount of shared memory ever used by OpenSIPS processes.Gauge
opensips_shmem_real_used_sizeAmount of shared memory requested by OpenSIPS processes + malloc overheadGauge
opensips_shmem_total_sizeTotal size of shared memory available to OpenSIPS processes.Gauge
opensips_shmem_used_sizeAmount of shared memory requested and used by OpenSIPS processes.Gauge
opensips_sl_received_ACKsThe number of received_ACKs.Counter
opensips_sl_repliesThe number of replies.typeCounter
opensips_sl_xxx_repliesThe number of replies that don't match any other reply status.Counter
opensips_sl_failuresThe number of failures.Counter
opensips_sl_sent_err_replies_totalThe total number of sent_err_replies.Counter
opensips_sl_sent_replies_totalThe total number of sent_replies.Counter
opensips_tm_inuse_transactionsNumber of transactions existing in memory at current time.Counter
opensips_tm_local_replies_totalTotal number of replies local generated by TM module.Counter
opensips_tm_received_replies_totalTotal number of total replies received by TM module.Counter
opensips_tm_relayed_replies_totalTotal number of replies received and relayed by TM module.Counter
opensips_tm_transactions_totalTotal number of transactions. (TM module)typeCounter
opensips_tmx_transactions_totalTotal number of transactions. (TMX module)typeCounter
opensips_tmx_UAS_transactionsTotal number of transactions created by received requests.typeCounter
opensips_tmx_UAC_transactionsTotal number of transactions created by local generated requests.Counter
opensips_tmx_inuse_transactionsNumber of transactions existing in memory at current time.Gauge
opensips_tmx_active_transactionsNumber of ongoing transactions at current time.Gauge
opensips_tmx_repliesTotal number of replies.typeCounter
opensips_uri_negative_checksAmount of negative URI checks.Counter
opensips_uri_positive_checksAmount of positive URI checks.Counter
opensips_usrloc_registered_users_totalTotal number of AOR existing in the USRLOC memory cache for all domains.Counter
opensips_usrloc_contactsNumber of contacts existing in the USRLOC memory cache for that domain.domainGauge
opensips_usrloc_expiresTotal number of expired contacts for that domain.domainGauge
opensips_usrloc_usersNumber of AOR existing in the USRLOC memory cache for that domain.domainGauge

Processors

There are processors available per 'module' of OpenSIPS. The processors take the statistics from the OpenSIPS socket and turn it into a Prometheus metric. You can recognise a processor by the naming convention of the metrics. For example theopensips_core_replies metric comes from the core module and its processor can be found in ./processors/core_processor.

You can find out more about the available modules in the OpenSIPS documentation.

Filtering enabled processors

It is possible to select what processors you want metrics from. You can do this by appending collect[] parameters to your request. If for example you only want to get metrics about the core and usrloc module you can do this as follows:

curl localhost:9434/metrics?collect[]=core:&collect[]=usrloc:

Note: You have to append : to the module name for this to work.

Development

To work on opensips_exporter, get a recent Go, get a recent dep, and run:

go get -u github.com/VoIPGRID/opensips_exporter

While developing, make sure to run dep ensure often enough to keep dependencies up-to-date.

The github.com/VoIPGRID/opensips_exporter/opensips package contains the implementation of the interactions with OpenSIPS needed to get statistics from the mi_datagram Unix socket of a running OpenSIPS. For tests, there is a mock in the ./internal/mock package.

Metrics from different OpenSIPS modules are extracted by processors defined in the ./processors package. To extend this exporter with metrics from other modules create your own processor and implement the Collector interface. See the other processors for inspiration.

Contributing

See the CONTRIBUTING.md file on how to contribute to this project.

Contributors

See the CONTRIBUTORS.md file for a list of contributors to the project.

License

opensips_exporter is made available under the Apache 2.0 license. See the LICENSE file for more info.