# Aggregate Nginx Metrics

**URL:** <https://discuss.elastic.co/t/aggregate-nginx-metrics/42187>\
**Category:** Logstash\
**Created:** [February 18, 2016, 7:55pm UTC](https://discuss.elastic.co/t/aggregate-nginx-metrics/42187 "2016-02-18T19:55:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeferson\_Martins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jeferson_martins/32/5849_2.png) [@Jeferson\_Martins](https://discuss.elastic.co/u/Jeferson_Martins)\
**Post date:** [February 18, 2016, 7:55pm UTC](https://discuss.elastic.co/t/aggregate-nginx-metrics/42187/1 "2016-02-18T19:55:46Z")

</div>

Hi,

Today I use StatsD to generate metrics about Nginx access, for example:

- how many requests in especific URL;
- how many 5XX/4XX/3XX/2XX httpcode for especific application

but I have a problem with application URL when the parameter used is in URL before "?".

For example:

- [http://www.myapp.com.br/application/version/123](http://www.myapp.com.br/application/version/123)
- [http://www.myapp.com.br/application/version/123/page/784](http://www.myapp.com.br/application/version/123/page/784)

and I have to transform this URLs in this in Logstash before send to StatsD to Aggregate correctlly:

- [http://www.myapp.com.br/application/version/{id}](http://www.myapp.com.br/application/version/%7Bid%7D)
- [http://www.myapp.com.br/application/version/{id}/page/{id}](http://www.myapp.com.br/application/version/%7Bid%7D/page/%7Bid%7D)

the problem is how every request the parameters are diferent, the StatsD not aggregate and I have to change the URL before send to StastD.

There is a better way to do this? Maybe not using StatsD?

I saw the metric filter plugin in Logstash but I will to make the same substituition in the URLs 😭

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [February 22, 2016, 7:05pm UTC](https://discuss.elastic.co/t/aggregate-nginx-metrics/42187/2 "2016-02-22T19:05:13Z")

</div>

You can use a grok filter to extract pieces of a string (the parts inbetween the variable parts) and put them back together with placeholders instead of the actual values. You might also be able to use a mutate filter and its gsub option.

---

<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:** [July 6, 2017, 5:10am UTC](https://discuss.elastic.co/t/aggregate-nginx-metrics/42187/3 "2017-07-06T05:10:16Z")

</div>


