Skip to content
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

Merged
merged 8 commits into from
Mar 3, 2021
Merged

Add new article on prometheus #196

merged 8 commits into from
Mar 3, 2021

Conversation

tdegiacinto
Copy link
Contributor

No description provided.

Copy link
Contributor

@francoislg francoislg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 GG

_posts/2019-05-17-prometheus-memory.md Outdated Show resolved Hide resolved
_posts/2019-05-17-prometheus-memory.md Outdated Show resolved Hide resolved
_posts/2019-05-17-prometheus-memory.md Outdated Show resolved Hide resolved
_posts/2019-05-17-prometheus-memory.md Outdated Show resolved Hide resolved
_posts/2019-05-17-prometheus-memory.md Outdated Show resolved Hide resolved
_posts/2019-05-17-prometheus-memory.md Outdated Show resolved Hide resolved
_posts/2019-05-17-prometheus-memory.md Outdated Show resolved Hide resolved
_posts/2019-05-17-prometheus-memory.md Outdated Show resolved Hide resolved
_posts/2019-05-17-prometheus-memory.md Outdated Show resolved Hide resolved
_posts/2019-05-17-prometheus-memory.md Outdated Show resolved Hide resolved
Copy link
Member

@malaporte malaporte left a 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kubernetes

Suggested change
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 :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Go profiling is a nice debugging tool.
* The Go profiler is a nice debugging tool.

tdegiacinto and others added 2 commits October 28, 2019 12:16
Taken previous comments into account
Still a few questions
Copy link
Collaborator

@amoreauCoveo amoreauCoveo left a 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:

_posts/2019-05-17-prometheus-memory.md Outdated Show resolved Hide resolved
_posts/2019-05-17-prometheus-memory.md Outdated Show resolved Hide resolved
_posts/2019-05-17-prometheus-memory.md Outdated Show resolved Hide resolved
_posts/2019-05-17-prometheus-memory.md Outdated Show resolved Hide resolved
_posts/2019-05-17-prometheus-memory.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@amoreauCoveo amoreauCoveo left a 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.
Copy link
Collaborator

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.
Copy link
Collaborator

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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks (missing s)

@amoreauCoveo amoreauCoveo merged commit 5fcd0ab into gh-pages Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants