Post your custom data

You can send custom metrics to Middleware Backend Using the API given below

POST https://{ACCOUNT-UID}.middleware.io/v1/metrics

You can use this curl request to understand how to send a metric to Middleware.

curl -X POST "https://{ACCOUNT-UID}.middleware.io/v1/metrics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d @- << EOF
{
  "resource_metrics": [
    {
      "resource": {
        "attributes": [
          {
            "key": "mw.account_key",
            "value": {
              "string_value": {ACCOUNT-API-KEY}
            }
          },
          {
            "key": "mw.resource_type",
            "value": {
              "string_value": "custom"
            }
          }
        ]
      },
      "scope_metrics": [
        {
          "metrics": [
            {
              "name": "swap-usage",
              "description": "SWAP usage",
              "unit": "Bytes",
              "gauge": {
                "data_points": [
                  {
                    "attributes": [
                      {
                        "key": "device",
                        "value": {
                          "string_value": "nvme0n1p4"
                        }
                      }
                    ],
                    "start_time_unix_nano": 1673435153000000000,
                    "time_unix_nano": 1673435153000000000,
                    "asInt": 4000500678
                  }
                ]
              }
            }
          ]
        }
      ]
    }
  ]
}
EOF

Note: We accept data in OTLP/HTTP format https://opentelemetry.io/docs/reference/specification/protocol/otlp/#otlphttp as you can see in the sample above.

Add data to Existing Middleware Resource Types

If you want to add your custom data to Existing Middleware Resource Types, you will have to add resource_attributes according to the list given below

Ex. If you want to add a metric for a “host” - you will need to add “host.id” resource attribute in your request body. Refer the table given below for the full list of supported types.

TypeResource Attributes RequiredData will be stored to this Dataset
hosthost.idHost Metrics
k8s.nodek8s.node.uidK8s Node Metrics
k8s.podk8s.pod.uidK8s POD metrics
k8s.deploymentk8s.deployment.uidK8s Deployment Metrics
k8s.daemonsetk8s.daemonset.uid~
k8s.replicasetk8s.replicaset.uid~
k8s.statefulsetk8s.statefulset.uid~
k8s.namespacek8s.namespace.uid~
serviceservice.name~
osos.type~

Add purely custom data

If you want to add data that does not fall under the existing resource types, you have to pass resource_attributes as given below

mw.resource_type: custom

Data added using this resource attributes will be available under Custom Metrics Dataset