Schedule a demo

API monitoring with Grafana Cloud metrics

Zato integrates with Grafana Cloud to let you track the health of your APIs and integrations in real-time.

You can monitor system resources, push custom metrics from your services, and build dashboards to visualize performance trends. You can also set up alerts on the metrics that matter to you, so you know about issues before they become problems.

What you get

  • API performance - How many req/s your services process
  • System metrics - CPU, memory, disk, filesystem, network and load statistics from your Zato containers
  • Custom metrics and pre-built dashboards - Push your own metrics from services and make use of pre-built dashboard templates

Prerequisites

To configure the integration, you need:

  • A Grafana Cloud account (any tier will work fine)
  • Your Grafana Cloud instance ID
  • An API key with metrics:write permissions
  • Your endpoint URL

To obtain these credentials:

  1. Log in to your Grafana Cloud account at grafana.com
  2. Go to My AccountGrafana Cloud portal
  3. Click on your stack name (by default, it's the same as your subdomain on grafana.com)
  4. Navigate to OpenTelemetry section
  5. Note down the Instance ID and endpoint URL
  6. Click Generate now in the "Password / API Token" field, while making sure it has metrics:write permissions (which should be among the default ones already)

Configuring Grafana Cloud in Zato

To configure the integration:

  1. Go to Monitoring → Grafana Cloud in your Zato dashboard
  2. Slide the toggle to enable the integration
  3. Enter your Instance ID from Grafana Cloud
  4. Enter your API key
  5. Enter your Endpoint URL (e.g. https://otlp-gateway-prod-us-central-0.grafana.net/otlp)
  6. Click Test connection to verify your credentials
  7. Click Save to apply the configuration
  8. The system will restart components to apply the changes

Testing the connection

Before saving, click Test connection to verify that Zato can reach your Grafana Cloud endpoint with the provided credentials.

If the test fails, you will see the error message returned by Grafana Cloud. Common issues include:

  • Invalid credentials - double-check your Instance ID and API key
  • Wrong endpoint - ensure you're using the correct endpoint from the OpenTelemetry section
  • Network issues - verify your container can reach the internet

Viewing service metrics

Every time a service is invoked, Zato automatically increments a counter metric in Grafana Cloud. This happens without any code changes on your part.

Service metrics use the naming pattern zato_service_<service_name>_total where dots and hyphens in the service name are replaced with underscores. The _total suffix is added automatically by Grafana.

For example, a service named demo.ping will appear in Grafana Cloud as zato_service_demo_ping_total.

To find your service metrics:

  • Switch to the Code mode (check the yellow arrow in the screenshot below)
  • Search for zato_service_
  • You will see all your services listed

  • For instance, use the rate() function to calculate requests per second:
rate(zato_service_demo_ping_total[1m])

This shows requests per second averaged over 1 minute. Adjust the interval as needed ([5m], [30s], etc.).

Building a dashboard

You can create dashboards to visualize service performance:

  1. Go to DashboardsNewNew Dashboard
  2. Add a new panel
  3. Use a query like rate(zato_service_demo_ping_total[1m]) to show requests per second
  4. Add more panels for other services you want to monitor
  5. Save the dashboard

This lets you track request rates, spot traffic patterns, and identify load trends across your API platform.

Pushing custom metrics from services

Use self.metrics.push to send custom metrics from your services to Grafana Cloud. This lets you track business-level indicators alongside system metrics.

Available methods

Your services have access to two metrics methods:

  • self.metrics.push(name, value) - Sets a gauge metric to a specific value. Use this for values that go up and down, like queue depths, temperatures, or percentages.

  • self.metrics.incr(name, value=1) - Increments a counter metric. Use this for values that only increase, like total requests processed or errors encountered.

Basic example

# -*- coding: utf-8 -*-

from zato.server.service import Service

class FlightBoardingStatus(Service):

    def handle(self):

        # Get boarding data from the request
        passengers_boarded = self.request.payload['passengers_boarded']
        passengers_total = self.request.payload['passengers_total']

        # Calculate boarding percentage
        boarding_percentage = (passengers_boarded / passengers_total) * 100

        # Push metrics to Grafana Cloud
        self.metrics.push('airport.flight.passengers_boarded', passengers_boarded)
        self.metrics.push('airport.flight.boarding_percentage', boarding_percentage)

        # Continue with business logic
        self.response.payload = {'status': 'ok', 'boarding_percentage': boarding_percentage}

How to find your custom metrics in Grafana Cloud

After pushing metrics from your service, follow these steps to locate them:

  1. Go to your Grafana Cloud instance (e.g. https://example.grafana.net)
  2. Click Explore in the left sidebar
  3. Select your Prometheus data source (it will have "prom" in its name)
  4. Switch to Code mode using the toggle in the query editor
  5. Type the name of your metric, for example airport_flight_passengers_boarded
  6. Click Run query to see the data
  7. (End of steps)

Note that dots in metric names are automatically converted to underscores by Grafana. So airport.flight.passengers_boarded becomes airport_flight_passengers_boarded.

Building a dashboard for custom metrics

To create a dashboard that displays your custom metrics:

  1. In Grafana Cloud, go to Dashboards in the left sidebar
  2. Click NewNew Dashboard
  3. Click Add visualization
  4. Select your Prometheus data source
  5. In the query editor, switch to Code mode
  6. Enter your metric name, for example: airport_flight_boarding_percentage
  7. Set the panel title to something descriptive like "Boarding progress"
  8. Click Apply to add the panel
  9. Click Save (disk icon) to save your dashboard
  10. (End of steps)

Filtering by service name

Every metric pushed through self.metrics.push or self.metrics.incr includes a service label with the name of the service that sent it. This lets you filter metrics by service.

For example, if you have multiple services pushing the same metric name:

airport_flight_passengers_boarded{service="my.boarding.service"}

Other use cases

The same approach applies to any domain where you need to track business or operational metrics in real-time.

In cybersecurity, services processing events from SIEM systems can push metrics for failed authentication attempts, high-severity incidents, current threat levels, and blocked IP counts - letting security teams build dashboards that show attack patterns and response effectiveness.

In telecommunications, services receiving data from network equipment can push metrics for active calls per switch, signal strength, dropped call counts, bandwidth utilization, and SMS queue depths - giving network operations teams visibility into capacity, quality degradation, and congestion patterns.

Setting up alerts on custom metrics

Once your custom metrics are in Grafana Cloud, you can create alerts:

  1. Go to AlertingAlert rules in the left sidebar
  2. Click New alert rule
  3. In the query section, enter your metric, for example: security_auth_failures
  4. Use rate() to calculate failures per second: rate(security_auth_failures[5m])
  5. Set a threshold condition, such as "is above 10"
  6. Configure notification channels (email, Slack, etc.)
  7. Click Save rule

Importing pre-built dashboards

Since Zato exports metrics using OpenTelemetry Protocol (OTLP), you can use any OTLP-compatible dashboard template from the Grafana community. This gives you access to hundreds of pre-built dashboards without additional configuration.

To import a dashboard:

  1. In Grafana Cloud, go to DashboardsNewImport
  2. Enter the dashboard ID or search by name
  3. Select the dashboard and click Import
  4. Choose your Prometheus data source
  5. The dashboard will display your Zato container metrics

These community dashboards work with Zato's OTLP metrics:

  • OpenTelemetry Host Metrics (ID: 20376) - CPU, memory, disk, network, and filesystem metrics adapted from Node Exporter format. Good starting point for container monitoring.

  • OTEL Host Metrics (ID: 23319) - Alternative host metrics dashboard with a different layout.

  • OpenTelemetry Collector (ID: 15983) - Monitors the telemetry pipeline itself, useful for debugging metric delivery issues.

To import by ID, paste the number directly into the import dialog instead of searching by name.

Using env. variables to persist configuration

To automatically configure Grafana Cloud when your container starts, using environment variables, as below:

docker run -it \
  -e Zato_Grafana_Cloud_Instance_ID=123456 \
  -e Zato_Grafana_Cloud_API_Key=your-api-key-here \
  -e Zato_Grafana_Cloud_Endpoint=https://otlp-gateway-prod-us-central-0.grafana.net/otlp \
  zatosource/zato-4.1

Environment variables take precedence over dashboard configuration. This is useful for:

  • Automated DevOps deployments
  • Kubernetes configurations
  • CI/CD pipelines where credentials are injected at runtime