# Observability > Statsd

# StatsD

Artillery can send metrics to any StatsD-compatible backend, providing a simple and widely-supported protocol for metrics collection.

## Quick Start

```yaml
config:
  plugins:
    publish-metrics:
      - type: statsd
        host: localhost
        port: 8125
```

## Configuration

### Configuration Options

| Name     | Description                                                              |
| -------- | ------------------------------------------------------------------------ |
| `type`   | Set to `statsd`                                                          |
| `host`   | Hostname/IP of the StatsD server (defaults to `127.0.0.1`)              |
| `port`   | Port of the StatsD server (defaults to `8125`)                          |
| `prefix` | Prefix for metric names created by Artillery (defaults to `artillery.`)  |

## Examples

### Basic Configuration

```yaml
config:
  plugins:
    publish-metrics:
      - type: statsd
        prefix: 'artillery.publish_metrics_plugin.'
```

### Custom Host and Port

```yaml
config:
  plugins:
    publish-metrics:
      - type: statsd
        host: metrics.example.com
        port: 8126
        prefix: 'loadtest.'
```

### Multiple Environments

```yaml
config:
  plugins:
    publish-metrics:
      - type: statsd
        host: '{{ $env.STATSD_HOST }}'
        port: '{{ $env.STATSD_PORT }}'
        prefix: 'artillery.{{ $env.ENVIRONMENT }}.'
```

## Compatible Backends

The StatsD integration works with any StatsD-compatible backend:

* **Original StatsD**: The original Etsy StatsD daemon
* **Telegraf**: InfluxData's metrics collector (see [InfluxDB integration](/docs/observability/influxdb))
* **Datadog Agent**: Can receive StatsD metrics (see [Datadog integration](/docs/observability/datadog))
* **AWS CloudWatch Agent**: Supports StatsD protocol
* **Graphite**: With StatsD frontend
* **Prometheus**: Via statsd\_exporter

## Metric Format

Artillery sends the following metric types to StatsD:

* **Counters**: For counts (e.g., total requests, errors)
* **Timers**: For latencies (e.g., response times)
* **Gauges**: For concurrent users and other measurements

Example metric names (with default prefix):

* `artillery.http.requests` - Total HTTP requests
* `artillery.http.response_time` - Response time measurements
* `artillery.errors.ECONNREFUSED` - Connection errors
* `artillery.vusers.active` - Active virtual users

## Best Practices

1. **Use namespacing**: Include environment and service names in your prefix
2. **Monitor UDP buffer**: StatsD uses UDP, which can drop packets under high load
3. **Local StatsD relay**: Consider running a local StatsD relay to buffer metrics
4. **Consistent prefixes**: Use consistent prefixes across all your load tests

## Debugging

To verify metrics are being sent, you can:

1. Use `tcpdump` to monitor UDP traffic:
   ```bash
   tcpdump -i any -n udp port 8125
   ```

2. Run a simple StatsD server for testing:
   ```bash
   nc -lu 8125
   ```

3. Check your StatsD backend's logs and dashboards
