> ## Documentation Index
> Fetch the complete documentation index at: https://docs.megaport.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Setting up OpenMetrics for Service Monitoring

> This help topic describes how to set up the Prometheus / OpenMetrics Megaport API to monitor the status of Megaport services.

<Note>
  This feature is currently in Beta and the format is subject to change.
</Note>

This topic describes an example configuration for setting up the Prometheus / OpenMetrics endpoint in Megaport's API.

OpenMetrics is a specification for representing and exchanging metrics data in a standardized format, primarily influenced by the Prometheus exposition format.

With the OpenMetrics endpoint integrated into Megaport's API, this allows you to expose existing service monitoring information.

In the Prometheus configuration example below, the scrape interval is set to one minute, but the network is only polled every five minutes. You will need to consider this in your PromQL/Grafana dashboarding.

Before you begin, obtain a valid access token. For more information, see [Creating an API Key](/api/api-key).

### Megaport API details

* **API**: /v1/openmetrics
* **Authentication**: API key/OAuth2

## Example Prometheus Configuration

```yaml theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}

global:
  scrape_interval: 5m

scrape_configs:
  - job_name: megaport
    static_configs:
      - targets: ["api.megaport.com"]
    scheme: https
    metrics_path: /v1/openmetrics
    oauth2:
      token_url: https://auth-m2m.megaport.com/oauth2/token
      client_id: <api key>
      client_secret: <api secret>

```

## Metrics

The endpoint currently exports these metrics for all services.

### Port

```text theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}

# HELP megaport_service_input_errors_total The total number of input errors.
# TYPE megaport_service_input_errors_total counter
# HELP megaport_service_optical_receive_power_dbm Optical receive power level in dBm.
# TYPE megaport_service_optical_receive_power_dbm gauge
# HELP megaport_service_optical_transmit_power_dbm Optical transmit power level in dBm.
# TYPE megaport_service_optical_transmit_power_dbm gauge
# HELP megaport_service_output_errors_total The total number of output errors.
# TYPE megaport_service_output_errors_total counter
# HELP megaport_service_receive_bytes_total The total number of bytes received.
# TYPE megaport_service_receive_bytes_total counter
# HELP megaport_service_receive_packets_total The total number of packets received.
# TYPE megaport_service_receive_packets_total counter
# HELP megaport_service_transmit_bytes_total The total number of bytes transmitted.
# TYPE megaport_service_transmit_bytes_total counter
# HELP megaport_service_transmit_packets_total The total number of packets transmitted.
# TYPE megaport_service_transmit_packets_total counter
# HELP megaport_service_up Operational status of the service.
# TYPE megaport_service_up gauge

```

### VXC

```text theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}

# HELP megaport_service_receive_bytes_total The total number of bytes received.
# TYPE megaport_service_receive_bytes_total counter
# HELP megaport_service_receive_packets_total The total number of packets received.
# TYPE megaport_service_receive_packets_total counter
# HELP megaport_service_transmit_bytes_total The total number of bytes transmitted.
# TYPE megaport_service_transmit_bytes_total counter
# HELP megaport_service_transmit_packets_total The total number of packets transmitted.
# TYPE megaport_service_transmit_packets_total counter
# HELP megaport_service_up Operational status of the service.
# TYPE megaport_service_up gauge

```

### MCR

```text theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}

# HELP megaport_service_receive_bytes_total The total number of bytes received.
# TYPE megaport_service_receive_bytes_total counter
# HELP megaport_service_receive_packets_total The total number of packets received.
# TYPE megaport_service_receive_packets_total counter
# HELP megaport_service_transmit_bytes_total The total number of bytes transmitted.
# TYPE megaport_service_transmit_bytes_total counter
# HELP megaport_service_transmit_packets_total The total number of packets transmitted.
# TYPE megaport_service_transmit_packets_total counter
# HELP megaport_service_up Operational status of the service.
# TYPE megaport_service_up gauge

```

### MVE

```text theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}

# HELP megaport_service_receive_bytes_total The total number of bytes received.
# TYPE megaport_service_receive_bytes_total counter
# HELP megaport_service_receive_packets_total The total number of packets received.
# TYPE megaport_service_receive_packets_total counter
# HELP megaport_service_transmit_bytes_total The total number of bytes transmitted.
# TYPE megaport_service_transmit_bytes_total counter
# HELP megaport_service_transmit_packets_total The total number of packets transmitted.
# TYPE megaport_service_transmit_packets_total counter
# HELP megaport_service_up Operational status of the service.
# TYPE megaport_service_up gauge

```

## Helpful references

* [Monitoring Service Status with the API](/api/monitoring)
* [OpenMetrics](https://openmetrics.io/)
* [Grafana](https://grafana.com/)
* [Prometheus Documentation](https://prometheus.io/docs/introduction/overview/)
