Skip to content

Example Setup

Jeffrey Jones edited this page Apr 1, 2023 · 9 revisions

Example Setup

This setup is an example that uses the Grafana cloud to collect, store and display metrics. This guide will setup the following systems where data flows from DCS to the Grafana cloud:

graph TD;
    DCS-Dedicated-Server-->DCS-gRPC;
    DCS-gRPC-->Telemachus;
    Telemachus-->OpenTelemetry-Collector;
    OpenTelemetry-Collector-->Grafana-Cloud;
Loading
  • DCS-Dedicated-Server Is your actual DCS dedicated server written by Eagle Dynamics.
  • DCS-gRPC Is a plugin for the DCS server, written by volunteers, that allows for remote access to APIs.
  • Telemachus Connects to DCS-gRPC and uses various APIs to collect metrics to post them to an OpenTelemetry endpoint.
  • OpenTelemetry-Collector is a program written by the OpenTelemetry foundation that listens to metrics and can transform and distribute them.
  • Grafana Cloud is a SaaS that receives metrics and allows you to visualise, alarm and perform other actions based on metrics.

DCS-gRPC

It is assumed that you already have DCS-gRPC setup. See the installation guide for it if you haven't yet set it up.

Grafana Account

Go to https://grafana.com/ and register a free account. Grafana prides itself on having an (actually useful) free forever plan. The amount of Data collected by Telemachus can fit within these limits.

Minimal OpenTelemetry Collector

Download the latest version from the releases page.

An example OpenTelemetry Collector config that connects the collector to the Grafana cloud is below. Make sure to replace the placeholder values with real values taken from your Grafana account Prometheus endpoint settings.

receivers:
  otlp:
    protocols:
      grpc:

processors:
  batch:

exporters:
  logging:
  prometheusremotewrite:
    # For example: https://12345:afakagwuefygkufg@prometheus-prod-10-prod-us-central-0.grafana.net/api/prom/push
    endpoint: "https://YOUR_ACCOUNT_ID:YOUR_APP_TOKEN@THE_PUSH_URL"

service:
 pipelines:
   metrics:
     receivers: [otlp]
     processors: [batch]
     exporters: [prometheusremotewrite, logging]

Once you have configured the OpenTelemetry Collector then run it.

For a more in-depth configuration file that records OS level metrics and relies on the Contrib release of OpenTelemetry see OpenTelemetry Advanced Config

See this guide background information on getting started with the Open Telemetry ecosystem.

Telemachus

This guide assumes you are running Telemachus on the same server as the OpenTelemetry Collector. The OpenTelemetry Collector must be running for Telemachus to connect to it.

  1. Download Telemachus from https://github.com/DCS-gRPC/Telemachus/releases and extract into a folder of your choice.
  2. Modify the configuration.yaml file to suit your installation. The file has comments that explain the various options.
  3. Run the bot using the Telemachus.exe or optionally run as a Windows Service (See below). For the initial runs we recommend not running as a service to make sure everything is setup correctly.

Install as a windows service

Run the following command in a Powershell window with administrator permissions, making sure to change the path to point to the correct location.

New-Service -Name Telemachus -BinaryPathName C:\YOUR\PATH\TO\Telemachus.exe -Description "Metrics application for DCS-gRPC" -DisplayName "Telemachus" -StartupType Automatic

Startup

Make sure the DCS Dedicated Server is running, make sure that DCS-gRPC is installed and running and make sure that the OpenTelemetry Collector and Telemachus are running.

At this point, if everything is working, then metrics will be flowing into the Prometheus database in the Grafana Cloud.

Grafana Dashboard

Access your grafana instance, create a dashboard and paste the following panel JSON to create an example dashboard with a 4 graphs demonstrating some different things Grafana can do. Explaining everything that is possible in Grafana is out of scope for this example document. You are encouraged to explode the possibilities for yourself.

{
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "grafana",
          "uid": "-- Grafana --"
        },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "target": {
          "limit": 100,
          "matchAny": false,
          "tags": [],
          "type": "dashboard"
        },
        "type": "dashboard"
      }
    ]
  },
  "description": "Statistics relevant to the performance of a DCS Game Session",
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 2,
  "id": 18,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 20,
      "panels": [],
      "title": "DCS Game Statistics",
      "type": "row"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "grafanacloud-prom"
      },
      "description": "Simulation FPS of the DCS server and a 10 minute moving average",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "none"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 1
      },
      "id": 22,
      "interval": "1s",
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "grafanacloud-prom"
          },
          "editorMode": "builder",
          "expr": "sum by(session_id) (simulation_frames_per_second_gauge{session_id=\"$session_id\"})",
          "legendFormat": "FPS",
          "range": true,
          "refId": "fps"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "grafanacloud-prom"
          },
          "editorMode": "builder",
          "expr": "sum by(session_id) (avg_over_time(simulation_frames_per_second_gauge{session_id=\"$session_id\"}[10m])) > 5",
          "hide": false,
          "legendFormat": "Avg FPS",
          "range": true,
          "refId": "trend"
        }
      ],
      "title": "Server FPS",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "grafanacloud-prom"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 39,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "normal"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "decimals": 0,
          "mappings": [],
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "none"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Blue"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "blue",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Red"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "red",
                  "mode": "fixed"
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 1
      },
      "id": 24,
      "interval": "1s",
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "grafanacloud-prom"
          },
          "editorMode": "builder",
          "expr": "sum by(coalition, session_id) (players{coalition=\"Blue\", session_id=\"$session_id\"})",
          "legendFormat": "{{coalition}}",
          "range": true,
          "refId": "coalition"
        }
      ],
      "title": "Player Count",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "grafanacloud-prom"
      },
      "description": "The number of units currently active on the server",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 11,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "normal"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "decimals": 0,
          "mappings": [],
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "none"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Blue"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "blue",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Red"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "red",
                  "mode": "fixed"
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 9
      },
      "id": 39,
      "interval": "1s",
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "grafanacloud-prom"
          },
          "editorMode": "builder",
          "expr": "sum by(session_id, category) (units_per_server_gauge{session_id=\"$session_id\"}) > 0",
          "hide": false,
          "legendFormat": "{{category}}",
          "range": true,
          "refId": "ballistics"
        }
      ],
      "title": "Unit Count",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "grafanacloud-prom"
      },
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "decimals": 0,
          "mappings": [],
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "ms"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 9
      },
      "id": 38,
      "interval": "1s",
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "grafanacloud-prom"
          },
          "editorMode": "builder",
          "expr": "histogram_quantile(0.5, sum by(le, session_id) (rate(player_pings_bucket{session_id=\"$session_id\"}[$__rate_interval])))",
          "hide": false,
          "legendFormat": "p50",
          "range": true,
          "refId": "p50"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "grafanacloud-prom"
          },
          "editorMode": "builder",
          "expr": "histogram_quantile(0.9, sum by(le) (rate(player_pings_bucket{session_id=\"$session_id\"}[$__rate_interval])))",
          "hide": false,
          "legendFormat": "p90",
          "range": true,
          "refId": "p90"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "grafanacloud-prom"
          },
          "editorMode": "builder",
          "expr": "histogram_quantile(0.99, sum by(le) (rate(player_pings_bucket{session_id=\"$session_id\"}[$__rate_interval])))",
          "hide": false,
          "legendFormat": "p99",
          "range": true,
          "refId": "p100"
        }
      ],
      "title": "Player Pings",
      "type": "timeseries"
    }
  ],
  "refresh": "5s",
  "revision": 1,
  "schemaVersion": 38,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "current": {
          "isNone": true,
          "selected": false,
          "text": "None",
          "value": ""
        },
        "datasource": {
          "type": "prometheus",
          "uid": "grafanacloud-prom"
        },
        "definition": "simulation_frames_per_second_gauge",
        "description": "The unique mission session ID",
        "hide": 0,
        "includeAll": false,
        "label": "Session ID",
        "multi": false,
        "name": "session_id",
        "options": [],
        "query": {
          "query": "simulation_frames_per_second_gauge",
          "refId": "StandardVariableQuery"
        },
        "refresh": 2,
        "regex": "/.*session_id=\"(.*)\".*/",
        "skipUrlSync": false,
        "sort": 4,
        "type": "query"
      }
    ]
  },
  "time": {
    "from": "now-4h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "utc",
  "title": "Example DCS Dashboard",
  "uid": "xb1jujk4v",
  "version": 5,
  "weekStart": ""
}