Menu
Grafana Cloud

TensorFlow Serving integration for Grafana Cloud

TensorFlow Serving is an end-to-end open source platform for machine learning. The TensorFlow Serving integration uses the Grafana agent to collect metrics for monitoring a TensorFlow Serving instance, including aspects such as model request latency, model runtime latency, batch queuing latency, graph build time, and graph run time. The integration also supports the TensorFlow Serving Docker container logs being scraped by the agent using Promtail. An accompanying dashboard is provided to visualize these metrics and logs.

This integration supports TensorFlow Serving 2.10.0+.

This integration includes 2 useful alerts and 1 pre-built dashboard to help monitor and visualize TensorFlow Serving metrics and logs.

Before you begin

In order for the integration to work, you must configure TensorFlow Serving’s built in Prometheus metrics server.

It is required to first enable the Prometheus metrics as described in the TensorFlow Serving documentation.

Special configuration is also needed in order to enable the the Prometheus batching metrics. Batching configuration can be enabled as described in the TensorFlow Serving documentation.

Install TensorFlow Serving integration for Grafana Cloud

  1. In your Grafana Cloud stack, click Connections in the left-hand menu.
  2. Find TensorFlow Serving and click its tile to open the integration.
  3. Review the prerequisites in the Configuration Details tab and set up Grafana Agent to send TensorFlow Serving metrics and logs to your Grafana Cloud instance.
  4. Click Install to add this integration’s pre-built dashboard and alerts to your Grafana Cloud instance, and you can start monitoring your TensorFlow Serving setup.

Post-install configuration for the TensorFlow Serving integration

This integration supports metrics and logs from a TensorFlow Serving instance.

Enable the integration by adding the provided snippets to your agent configuration file.

If you want to show logs and metrics signals correlated in your dashboards, as a single pane of glass, ensure the following: job and instance label values must match for metrics and logs scrape config in your agent configuration file. job label must be set to integrations/tensorflow (already configured in the snippets). instance label must be set to a value that uniquely identifies your Tensorflow node. Please replace the default hostname value according to your environment - it should be set manually. Note that if you use localhost for multiple nodes, the dashboards will not be able to filter correctly by instance.

Additionally, this integration needs a name label to be set to tensorflow in the log scrape. This is already configured in the log snippet.

Configuration snippets for Grafana Agent

Below metrics.configs.scrape_configs, insert the following lines and change the URLs according to your environment:

    - job_name: integrations/tensorflow
      metrics_path: "/monitoring/prometheus/metrics"
      relabel_configs:
        - replacement: "<your-instance-name>"
          target_label: instance
      static_configs:
        - targets: ['localhost:8501']

Below logs.configs.scrape_configs, insert the following lines according to your environment.

    - job_name: integrations/tensorflow
      relabel_configs:
        - source_labels: ['__meta_docker_container_name']
          replacement: tensorflow
          target_label: name
        - source_labels: ['__meta_docker_container_name']
          replacement: integrations/tensorflow
          target_label: job
        - source_labels: ['__meta_docker_container_name']
          replacement: "<your-instance-name>"
          target_label: instance
      docker_sd_configs:
        - host: unix:///var/run/docker.sock
          refresh_interval: 5s
          filters:
            - name: name
              values: [tensorflow]

Full example configuration for Grafana Agent

Refer to the following Grafana Agent configuration for a complete example that contains all the snippets used for the TensorFlow Serving integration. This example also includes metrics that are sent to monitor your Grafana Agent instance.

integrations:
  agent:
    enabled: true
    relabel_configs:
    - action: replace
      source_labels:
      - agent_hostname
      target_label: instance
    - action: replace
      target_label: job
      replacement: "integrations/agent-check"
    metric_relabel_configs:
    - action: keep
      regex: (prometheus_target_.*|prometheus_sd_discovered_targets|agent_build.*|agent_wal_samples_appended_total|process_start_time_seconds)
      source_labels:
      - __name__
  prometheus_remote_write:
  - basic_auth:
      password: <your_prom_pass>
      username: <your_prom_user>
    url: <your_prom_url>
logs:
  configs:
  - clients:
    - basic_auth:
        password: <your_loki_pass>
        username: <your_loki_user>
      url: <your_loki_url>
    name: integrations
    positions:
      filename: /tmp/positions.yaml
    scrape_configs:
    - job_name: integrations/tensorflow
      relabel_configs:
        - source_labels: ['__meta_docker_container_name']
          replacement: tensorflow
          target_label: name
        - source_labels: ['__meta_docker_container_name']
          replacement: integrations/tensorflow
          target_label: job
        - source_labels: ['__meta_docker_container_name']
          replacement: "<your-instance-name>"
          target_label: instance
      docker_sd_configs:
        - host: unix:///var/run/docker.sock
          refresh_interval: 5s
          filters:
            - name: name
              values: [tensorflow]
metrics:
  configs:
  - name: integrations
    remote_write:
    - basic_auth:
        password: <your_prom_pass>
        username: <your_prom_user>
      url: <your_prom_url>
    scrape_configs:
    - job_name: integrations/tensorflow
      metrics_path: "/monitoring/prometheus/metrics"
      relabel_configs:
        - replacement: "<your-instance-name>"
          target_label: instance
      static_configs:
        - targets: ['localhost:8501']
  global:
    scrape_interval: 60s
  wal_directory: /tmp/grafana-agent-wal

Dashboards

The TensorFlow Serving integration installs the following dashboards in your Grafana Cloud instance to help monitor your system.

  • TensorFlow Serving overview

TensorFlow Serving overview dashboard 1

image

TensorFlow Serving overview dashboard 2

image

Alerts

The TensorFlow Serving integration includes the following useful alerts:

AlertDescription
TensorFlowModelRequestHighErrorRateCritical: More than 30% of all model requests are not successful.
TensorFlowServingHighBatchQueuingLatencyWarning: Batch queuing latency more than 5000000µs.

Metrics

The most important metrics provided by the TensorFlow Serving integration, which are used on the pre-built dashboard and Prometheus alerts, are as follows:

  • :tensorflow:core:graph_build_calls
  • :tensorflow:core:graph_build_time_usecs
  • :tensorflow:core:graph_run_time_usecs
  • :tensorflow:core:graph_runs
  • :tensorflow:serving:batching_session:queuing_latency_count
  • :tensorflow:serving:batching_session:queuing_latency_sum
  • :tensorflow:serving:request_count
  • :tensorflow:serving:request_latency_count
  • :tensorflow:serving:request_latency_sum
  • :tensorflow:serving:runtime_latency_count
  • :tensorflow:serving:runtime_latency_sum

Changelog

# 0.0.2 - January 2023

* Updated integration name to TensorFlow Serving

# 0.0.1 - December 2022

* Initial Release

Cost

By connecting your TensorFlow Serving instance to Grafana Cloud, you might incur charges. To view information on the number of active series that your Grafana Cloud account uses for metrics included in each Cloud tier, see Active series and dpm usage and Cloud tier pricing.