Akka HTTP configuration

Akka HTTP endpoints need to be selected for Telemetry using configuration. Cinnamon accesses the same configuration as used to configure an ActorSystem. The default configuration is in application.conf.

Server metrics

Server metrics are automatically enabled when Cinnamon’s Akka HTTP dependency is on the classpath.

It is possible to turn server-metrics off for a server with configuration, see Example configuration 3 here below.

Server metrics configuration

Endpoint metrics are not enabled by default. In other words, without any specific configuration, there will be no metrics for the endpoints.

Endpoint configuration settings are grouped per “host:port.” An actor system can run several Akka HTTP servers and when a server is started, Cinnamon will inquire the configuration to determine how to set things up.

The configuration should define the following settings:

Setting Explanation
host:port The IP address and port the setting is valid for. Can be set to "*:*" to be valid for all hosts/ports.
server-metrics An optional setting (by default set to on) that can be used to turn metrics off for server(s).
paths A section in which endpoint paths are defined with specific settings per endpoint.

Each endpoint in the paths section should define the following:

Setting Explanation
endpoint path The endpoint path to configure. A * wildcard can be used at the end to select all subpaths.
metrics Should be set to on, true or yes for metrics to be created.

Endpoint naming

By default, endpoint metrics created use the endpoint path as name for the metric. Let’s look at a couple of examples to clarify this feature:

Path directive Metric name
path(“customers”) customers
path(“customers” / IntNumber) customers/<Integer>
path(“customers” / IntNumber / “addresses” / LongNumber) customers/<Integer>/addresses/<Integer>
path(“accounts/type”) accounts/type
path(“accounts” / Segment) accounts/<String>

It is also possible to set the name programmatically.

Example configuration 1

The simplest configuration possible is the one that matches all paths, hosts and ports:

cinnamon.akka.http.servers {
  "*:*" {
    paths {
      "*" {
        metrics = on
      }
    }
  }
}

Example configuration 2

Below is an example configuration that is more specific than Example configuration 1:

cinnamon.akka.http.servers {
  "192.168.10.1:8080" {
    paths {
      "users/us/*" {
        metrics = on
      }
      "users/se/*" {
        metrics = on
      }
      "users/nz/*" {
        metrics = on
      }
    }
  }
}

The above configuration will create metrics for paths that map to users in us, se, or nz. Notice that all users in these domains are valid since we use * as part of the paths. Furthermore, this configuration is only valid for a server started on IP 192.168.10.1 and port 8080.

Example configuration 3

Turning all metrics off for a particular server:

cinnamon.akka.http.servers {
  "192.168.0.1:*" {
    server-metrics = off
  }
}

The server-metrics setting is optional and if not present it will automatically be set to on.

Client metrics configuration

Client metrics configuration settings are grouped per “host:port”. In the context of Akka HTTP client we refer to “host:port” as a service. Each service can define which “paths” should generate metrics.

The name used for the metric will be the first available in order out of programmatic Request.withName, configured service-name, otherwise host:port.

Let us look at a couple of client metrics configuration examples.

Example configuration 1

The simplest configuration possible is the one that matches all paths, hosts and ports:

cinnamon.akka.http.clients {
  "*:*" {
    paths {
      "*" {
        metrics = on
      }
    }
  }
}

With the above configuration all service calls will be monitored and metrics generated will be under the service name “:”.

Example configuration 2

In the configuration below we use the setting service-name which means that metrics will be generated in the context of “accountService” and “customerService”.

cinnamon.akka.http.clients {
  "192.168.10.1:*" {
    service-name = "accountService"
    paths {
      "*" {
        metrics = on
      }
    }
  },
  "192.168.10.10:8080" {
    service-name = "customerService"
    paths {
      "*" {
        metrics = on
      }
    }
  }
}

Example configuration 3

It is also possible to define what paths of a service that should generate and contribute to the metrics.

cinnamon.akka.http.clients {
  "192.168.10.1:8080" {
    paths {
      "customer/address/*" {
        metrics = on
      }
    }
  }
}

Note: On the contrary to server endpoint metrics, in which unique metrics are created per path endpoint, any defined paths in client metrics configuration contribute to one overall metrics per service.