-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new article on prometheus #196
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 GG
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool stuff. Couple of typos etc.
|
||
author: | ||
name: Thomas De Giacinto | ||
bio: Working in the Cloud infrastructure team | ||
image: tdegiacinto.jpg | ||
--- | ||
|
||
<!-- more --> | ||
Here at coveo we are using [Prometheus 2](https://prometheus.io/) for collecting all our monitoring metrics. It's known for being able to handle millions of time series with few resources. So when our pod was hiting its 30Gi memory limit we decided to dive into it to understand how memory is allocated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here at coveo we are using [Prometheus 2](https://prometheus.io/) for collecting all our monitoring metrics. It's known for being able to handle millions of time series with few resources. So when our pod was hiting its 30Gi memory limit we decided to dive into it to understand how memory is allocated. | |
Here at Coveo we are using [Prometheus 2](https://prometheus.io/) for collecting all our monitoring metrics. It's known for being able to handle millions of time series with few resources. So when our pod was hiting its 30Gi memory limit we decided to dive into it to understand how memory is allocated. |
|
||
For example some benchmark give the following metrics : | ||
Recently we ran in an issue were our prometheus pod was killed by kubenertes because it was reaching its 30Gi memory limit. Which was surprising considering the numbers of metrics we were collecting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kubernetes
Recently we ran in an issue were our prometheus pod was killed by kubenertes because it was reaching its 30Gi memory limit. Which was surprising considering the numbers of metrics we were collecting. | |
Recently we ran in an issue were our prometheus pod was killed by Kubernetes because it was reaching its 30Gi memory limit. Which was surprising considering the numbers of metrics we were collecting. |
|
||
For example some benchmark give the following metrics : | ||
Recently we ran in an issue were our prometheus pod was killed by kubenertes because it was reaching its 30Gi memory limit. Which was surprising considering the numbers of metrics we were collecting. | ||
For comparaison, some benchmark available on internet give the following statistics : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For comparaison, some benchmark available on internet give the following statistics : | |
For comparison, some benchmark available on the Internet give the following statistics : |
|
||
### Storage | ||
|
||
When prometheus scrape a target it retrieve thousands of metrics, which will be compacted into chunk and stored in block before being written on disk. Only the head block is writable, all other blocks are immutable. By default, a block contain 2h of data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When prometheus scrape a target it retrieve thousands of metrics, which will be compacted into chunk and stored in block before being written on disk. Only the head block is writable, all other blocks are immutable. By default, a block contain 2h of data. | |
When Prometheus scrapes a target it retrieve thousands of metrics, which will be compacted into chunk and stored in block before being written on disk. Only the head block is writable, all other blocks are immutable. By default, a block contain 2h of data. |
|
||
### Analyze memory usage | ||
|
||
Prometheus expose [Go](https://golang.org/) [profiling tools](https://golang.org/pkg/runtime/pprof/), so let see what we have. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prometheus expose [Go](https://golang.org/) [profiling tools](https://golang.org/pkg/runtime/pprof/), so let see what we have. | |
Prometheus exposes [Go](https://golang.org/) [profiling tools](https://golang.org/pkg/runtime/pprof/), so let see what we have. |
|
||
First thing we see that the memory usage is only 10 Go which means all 30Go remaining memory used, see by kubernetes, is in fact the cached memory used by mmap. | ||
|
||
Secondly we see that we have a huge amount of memory used by labels which indicate a probably high cardinality issue. High cardinality mean a metrics using a label which has plenty of different value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Secondly we see that we have a huge amount of memory used by labels which indicate a probably high cardinality issue. High cardinality mean a metrics using a label which has plenty of different value | |
Secondly we see that we have a huge amount of memory used by labels which indicate a probably high cardinality issue. High cardinality mean a metrics using a label which has plenty of different values. |
|
||
The tsdb binary has an `analyze` option which can retrieve many useful statistics on the tsdb database. | ||
|
||
So we decided to copy the disk storing our data from prometheus and mount it on a dedicated instance to run the analyze. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we decided to copy the disk storing our data from prometheus and mount it on a dedicated instance to run the analyze. | |
So we decided to copy the disk storing our data from prometheus and mount it on a dedicated instance to run the analysis. |
120963 container_spec_memory_reservation_limit_bytes | ||
``` | ||
|
||
We can see that the monitoring of one of the Kubernetes service(kubelet) seems to generate a lot of churn (which is normal considering that it expose all of the container metrics and that container rotate often ) and that the id label has an high cardinality. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can see that the monitoring of one of the Kubernetes service(kubelet) seems to generate a lot of churn (which is normal considering that it expose all of the container metrics and that container rotate often ) and that the id label has an high cardinality. | |
We can see that the monitoring of one of the Kubernetes service (kubelet) seems to generate a lot of churn (which is normal considering that it expose all of the container metrics and that container rotate often) and that the id label has an high cardinality. |
## What we learned | ||
|
||
* Labels in metrics have more impact on the memory usage than the metrics itself. | ||
* Memory seen by docker is not the memory really used by prometheus. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Memory seen by docker is not the memory really used by prometheus. | |
* Memory seen by Docker is not the memory really used by Prometheus. |
|
||
* Labels in metrics have more impact on the memory usage than the metrics itself. | ||
* Memory seen by docker is not the memory really used by prometheus. | ||
* Go profiling is a nice debugging tool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Go profiling is a nice debugging tool. | |
* The Go profiler is a nice debugging tool. |
Taken previous comments into account Still a few questions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still a few changes but nothing major :gg:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice post! :) Only minor language fixes left, and then ready to merge!
image: tdegiacinto.jpg | ||
--- | ||
|
||
At Coveo, we use [Prometheus 2](https://prometheus.io/) for collecting all of our monitoring metrics. Prometheus is known for being able to handle millions of time series with only a few resources. So when our pod was hiting its 30Gi memory limit, we decided to dive into it to understand how memory is allocated, and get to the root of the issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hitting (two t's)
|
||
<!-- more --> | ||
|
||
Recently, we ran into an issue were our prometheus pod was killed by kubenertes because it was reaching its 30Gi memory limit. This surprised us, considering the amount of metrics we were collecting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an issue where (missing h)
Should Kubernetes be capitalized? According to their website, I think they do. Same thing with Prometheus
<!-- more --> | ||
|
||
Recently, we ran into an issue were our prometheus pod was killed by kubenertes because it was reaching its 30Gi memory limit. This surprised us, considering the amount of metrics we were collecting. | ||
For comparison, benchmarks for a typical Prometheus installation usually look something like this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks (missing s)
No description provided.