---
title: Go-Expvar
description: Collect expvar-instrumented metrics and memory stats from your Go service.
breadcrumbs: Docs > Integrations > Go-Expvar
---

# Go-Expvar
Supported OS Integration version5.4.0


## Overview{% #overview %}

Track the memory usage of your Go services and collect metrics instrumented from Go's expvar package.

If you prefer to instrument your Go code using only [dogstats-go](https://github.com/DataDog/datadog-go), you can still use this integration to collect memory-related metrics.

**Minimum Agent version:** 6.0.0

## Setup{% #setup %}

### Installation{% #installation %}

The Go Expvar check is packaged with the Agent, so [install the Agent](https://app.datadoghq.com/account/settings/agent/latest) anywhere you run Go services to collect metrics.

### Configuration{% #configuration %}

#### Prepare the service{% #prepare-the-service %}

If your Go service doesn't use the [expvar package](https://golang.org/pkg/expvar) already, import it (`import "expvar"`). If you don't want to instrument your own metrics with expvar - that is you only want to collect your service's memory metrics - import the package using the blank identifier (`import _ "expvar"`). If your service doesn't already listen for HTTP requests (with the http package), [make it listen](https://golang.org/pkg/net/http/#ListenAndServe) locally just for the Datadog Agent.

{% tab title="Host" %}
#### Host{% #host %}

To configure this check for an Agent running on a host:

##### Connect the Agent{% #connect-the-agent %}

1. Edit the file `go_expvar.d/conf.yaml`, in the `conf.d/` folder at the root of your [Agent's configuration directory](https://docs.datadoghq.com/agent/guide/agent-configuration-files.md#agent-configuration-directory). See the [sample go_expvar.d/conf.yaml](https://github.com/DataDog/integrations-core/blob/master/go_expvar/datadog_checks/go_expvar/data/conf.yaml.example) for all available configuration options.

**Note**: If you don't configure a `metrics` list, the Agent still collects memstat metrics. Use `metrics` to tell the Agent which expvar vars to collect.

1. [Restart the Agent](https://docs.datadoghq.com/agent/guide/agent-commands.md#start-stop-and-restart-the-agent).

**Note**: The Go Expvar integration can potentially emit [custom metrics](https://docs.datadoghq.com/developers/metrics/custom_metrics.md), which may impact your [billing](https://docs.datadoghq.com/account_management/billing/custom_metrics.md). By default, there is a limit of 350 metrics. If you require additional metrics, contact [Datadog support](https://docs.datadoghq.com/help/).
{% /tab %}

{% tab title="Containerized" %}
#### Containerized{% #containerized %}

For containerized environments, see the [Autodiscovery Integration Templates](https://docs.datadoghq.com/agent/kubernetes/integrations.md) for guidance on applying the parameters below.

| Parameter            | Value                                    |
| -------------------- | ---------------------------------------- |
| `<INTEGRATION_NAME>` | `go_expvar`                              |
| `<INIT_CONFIG>`      | blank or `{}`                            |
| `<INSTANCE_CONFIG>`  | `{"expvar_url": "http://%%host%%:8080"}` |

{% /tab %}

### Validation{% #validation %}

[Run the Agent's status subcommand](https://docs.datadoghq.com/agent/guide/agent-commands.md#agent-status-and-information) and look for `go_expvar` under the Checks section.

## Data Collected{% #data-collected %}

### Metrics{% #metrics %}

|  |
|  |
| **go\_expvar.memstats.alloc**(gauge)                  | Bytes allocated and not yet freed*Shown as byte*                      |
| **go\_expvar.memstats.frees**(gauge)                  | Number of frees*Shown as operation*                                   |
| **go\_expvar.memstats.heap\_alloc**(gauge)            | Bytes allocated and not yet freed*Shown as byte*                      |
| **go\_expvar.memstats.heap\_idle**(gauge)             | Bytes in idle spans*Shown as byte*                                    |
| **go\_expvar.memstats.heap\_inuse**(gauge)            | Bytes in non-idle spans*Shown as byte*                                |
| **go\_expvar.memstats.heap\_objects**(gauge)          | Total number of allocated objects*Shown as item*                      |
| **go\_expvar.memstats.heap\_released**(gauge)         | Bytes released to the OS*Shown as byte*                               |
| **go\_expvar.memstats.heap\_sys**(gauge)              | Bytes obtained from system*Shown as byte*                             |
| **go\_expvar.memstats.lookups**(gauge)                | Number of pointer lookups*Shown as operation*                         |
| **go\_expvar.memstats.mallocs**(gauge)                | Number of mallocs*Shown as operation*                                 |
| **go\_expvar.memstats.num\_gc**(gauge)                | Number of garbage collections*Shown as garbage collection*            |
| **go\_expvar.memstats.pause\_ns.95percentile**(gauge) | 95th percentile of recent GC pause durations*Shown as nanosecond*     |
| **go\_expvar.memstats.pause\_ns.avg**(gauge)          | Average of recent GC pause durations*Shown as nanosecond*             |
| **go\_expvar.memstats.pause\_ns.count**(rate)         | Number of submitted GC pause durations*Shown as sample*               |
| **go\_expvar.memstats.pause\_ns.max**(gauge)          | Max GC pause duration*Shown as nanosecond*                            |
| **go\_expvar.memstats.pause\_ns.median**(gauge)       | Median GC pause duration*Shown as nanosecond*                         |
| **go\_expvar.memstats.pause\_total\_ns**(gauge)       | Total GC pause duration over lifetime of process*Shown as nanosecond* |
| **go\_expvar.memstats.total\_alloc**(gauge)           | Bytes allocated (even if freed)*Shown as byte*                        |
| **go\_expvar.memstats.total\_alloc.count**(count)     | Bytes allocated (even if freed) as monotonic count*Shown as byte*     |

### Events{% #events %}

The Go-Expvar check does not include any events.

### Service Checks{% #service-checks %}

The Go-Expvar check does not include any service checks.

## Troubleshooting{% #troubleshooting %}

Need help? Contact [Datadog support](https://docs.datadoghq.com/help/).

## Further Reading{% #further-reading %}

- [Instrument your Go apps with Expvar and Datadog](https://www.datadoghq.com/blog/instrument-go-apps-expvar-datadog)
