# How to gather more metrics (system and runtime metrics)

**URL:** <https://discuss.elastic.co/t/how-to-gather-more-metrics-system-and-runtime-metrics/234812>\
**Category:** APM\
**Tags:** go\
**Created:** [May 28, 2020, 7:59pm UTC](https://discuss.elastic.co/t/how-to-gather-more-metrics-system-and-runtime-metrics/234812 "2020-05-28T19:59:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![haile](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/haile/32/69337_2.png) [@haile](https://discuss.elastic.co/u/haile)\
**Post date:** [May 28, 2020, 7:59pm UTC](https://discuss.elastic.co/t/how-to-gather-more-metrics-system-and-runtime-metrics/234812/1 "2020-05-28T19:59:54Z")

</div>

**APM Agent language and version** :  
go/apm-agent-go-v1.8.0

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:  
I want to add system and runtime metrics in addition to default metrics by calling `GatherMetrics` method ([https://github.com/elastic/apm-agent-go/blob/95e54b2e24ea813e0d059e56dfe6c740681564cb/builtin\_metrics.go#L46](https://github.com/elastic/apm-agent-go/blob/95e54b2e24ea813e0d059e56dfe6c740681564cb/builtin_metrics.go#L46)) from Tracer but it looks there is no way to access it unless I'm mistaken. Do you think I missed something or is the method not exposed for consumption?

---

<div class="post-metadata">

**Author:** ![axw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axw/32/28197_2.png) [@axw](https://discuss.elastic.co/u/axw)\
**Post date:** [May 29, 2020, 3:30am UTC](https://discuss.elastic.co/t/how-to-gather-more-metrics-system-and-runtime-metrics/234812/2 "2020-05-29T03:30:32Z")

</div>

Welcome to the forum @haile!

You can use [Tracer.RegisterMetricsGatherer](https://pkg.go.dev/go.elastic.co/apm?tab=doc#Tracer.RegisterMetricsGatherer), passing in your own implementation of [MetricsGatherer](https://pkg.go.dev/go.elastic.co/apm?tab=doc#MetricsGatherer). There's [GatherMetricsFunc](https://pkg.go.dev/go.elastic.co/apm?tab=doc#GatherMetricsFunc) for convenience, for simple cases.

You can see an example in [https://github.com/elastic/apm-agent-go/blob/95e54b2e24ea813e0d059e56dfe6c740681564cb/metrics\_test.go#L135-L165](https://github.com/elastic/apm-agent-go/blob/95e54b2e24ea813e0d059e56dfe6c740681564cb/metrics_test.go#L135-L165).

There's also integration with a couple of external metrics APIs, if you prefer that approach:

- [https://pkg.go.dev/go.elastic.co/apm/module/apmprometheus?tab=doc](https://pkg.go.dev/go.elastic.co/apm/module/apmprometheus?tab=doc)
- [https://pkg.go.dev/go.elastic.co/apm/module/apmgometrics?tab=doc](https://pkg.go.dev/go.elastic.co/apm/module/apmgometrics?tab=doc)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 18, 2020, 11:30pm UTC](https://discuss.elastic.co/t/how-to-gather-more-metrics-system-and-runtime-metrics/234812/3 "2020-06-18T23:30:35Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
