Docs » µAPM Deployment Guide » Deploying the SignalFx Smart Agent

Deploying the SignalFx Smart Agent

The standard recommended deployment model for APM involves running the SignalFx Smart Agent on each host that runs traced applications. This ensures that a set of known, system-level metrics are reported to SignalFx to provide information about the host. Additionally, the traced applications on that host must report their trace spans to the Smart Agent, which will forward them to the Smart Gateway.

Sending trace spans through the Smart Agent gives the Smart Agent an opportunity to add certain tags to the spans that identify the host on which the spans were generated (e.g. the host tag that is the hostname, and cloud-provider specific tags such as AWSUniqueId if running on EC2). While this could be done in the tracer configuration as global tags, it is better to let the Smart Agent do it for consistency with the host metadata of metrics.

The Smart Agent will also generate internally-used metric time series called sf.int.service.heartbeat that our backend uses to match up the local service name of spans to the host(s) on which they are running. This metric is included in all subscriptions and does not count towards your custom metric limit.

Important

If you do not already have the Smart Agent running on your target hosts, see the information starting in the Smart Agent Overview to install the agent on those hosts using the method of your choice. Then continue with the steps below.

Once you have the agent running on your hosts, there are a few configuration options you need to set in your agent.yaml config file to enable trace forwarding and the host correlation datapoints:

# Where to send trace spans
traceEndpointUrl: http://host.of.smart.gateway:8080/v1/trace

# Enable the host/service heartbeat metrics
writer:
  sendTraceHostCorrelationMetrics: true

monitors:
  # Enable host metadata and basic system-level summary metrics
  - type: host-metadata
  - type: collectd/cpu
  - type: collectd/memory
  - type: collectd/interface
  - type: collectd/df
  - type: collectd/disk
  - type: collectd/signalfx-metadata
  # Enable the trace span listener server
  - type: trace-forwarder
    # This can be changed if needed; always HTTP only.
    # Use 0.0.0.0:9080 if your app runs in a container.
    listenAddress: 127.0.0.1:9080

Once you have the agent configured properly, the only thing left to do is configure your application’s tracer to send to the listenAddress specified in the trace-forwarder monitor configuration. The trace-forwarder monitor supports all of the span formats that our Smart Gateway supports (see Supported span formats). To configure your tracer, see µAPM Instrumentation Guide.

In the case of a slow downstream trace endpoint, the Smart Agent will buffer spans up to a default of 100,000 spans before dropping data to prevent unbounded memory consumption. The agent does not do any sampling, as that is handled in the Smart Gateway.

Note that in this minimal configuration, the footprint and impact of the Smart Agent on the host system is minimal. The CPU utilization of the Smart Agent will be directly related to the volume of trace spans that pass through it; it can comfortably handle over 100,000 spans/sec. The memory utilization of the Smart Agent should remain minimal during normal operation, but it may increase if the SignalFx Smart Gateway is unavailable and the Smart Agent needs to buffer trace spans.

Deploying on Kubernetes

When deploying the Smart Agent in a Kubernetes cluster, follow the normal instructions at Kubernetes Setup. To point your application pods to the Smart Agent instance running on the same node, the status.hostIP Downward API field provides a means of dynamically setting an environment variable in your pod that tells it which node it is running on. Here is a basic Deployment resource that has the host IP address injected as the envvar SIGNALFX_AGENT_HOST:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: myapp
  name: myapp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - env:
        - name: SIGNALFX_AGENT_HOST
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: status.hostIP
        image: my-image
        name: myapp

The Smart Agent’s DaemonSet is configured to run on the host network stack such that you can reach the trace forwarder endpoint (configured above) at the node’s primary IP address. You will have to configure your tracer to make use of that environment variable (see the docs for each language and tracer).