Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Implement Prometheus Metrics #4

Merged
merged 25 commits into from
Oct 30, 2019
Merged

Implement Prometheus Metrics #4

merged 25 commits into from
Oct 30, 2019

Conversation

viivek46
Copy link
Contributor

@viivek46 viivek46 commented Oct 20, 2019

What changes are proposed in this PR?

Resolves DCOS-59498

This PR Implement Prometheus Metrics for kudo Cassandra operator. we have used criteo cassandra_exporter to export Cassandra metrics.

To implement this below decisions are made :

  1. created different container in same pod to run metrics, and added related parameters.
  2. added config file cassandra-exporter-config-yml and downloaded jar for criteo cassandra exporter.
  3. Added label kudo.dev/servicemonitor: "true" and created service-monitor.yaml file to create Service Monitor object for service discovery.

How were these changes tested?

Manually tested and Below are steps to check

  1. Spin up Konvoy cluster and ensure cluster config is applied for kubectl.
  2. Install KUDO Cassandra operator
  3. Run command to create service-monito: kubectl create -f resources/service-monitor.yaml
  4. Wait 10-20 sec, and go to Prometheus dashboard. Type there Cassandra you will see "cassandra_stats".

@viivek46 viivek46 changed the title Metrics Implement Prometheus Metrics Oct 21, 2019
@viivek46
Copy link
Contributor Author

Hi @mpereira / @samvantran,
Few things that I need suggestion on :

  1. Metrics CPU/memory and METRICS PORT - what I should set default values.
  2. I copied cassandra-exporter-config-yml.yaml from criteo, should we go ahead with this or any things which we should remove from blacklist, also i am not sure how we can provide the customer option to enter blacklist values.

currently i am using curl to get cassandra_exporter jar from git, but once all things are ok i will upload this jar to http://downloads.mesosphere.com.

Copy link

@samvantran samvantran left a comment

Choose a reason for hiding this comment

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

Thanks @viivek46 ! I had a couple questions and few typo fixes but rest looks good. Great to have metrics exported. It would be great to add docs on what users need to do/set and where to go in order to view metrics. Similar to this

operator/operator.yaml Show resolved Hide resolved
operator/params.yaml Outdated Show resolved Hide resolved
@@ -46,7 +46,7 @@ spec:
imagePullPolicy: Always
# Dockerfile based on:
# https://github.com/docker-library/cassandra/blob/master/3.11/Dockerfile
image: mpereira/cassandra:3.11.4
image: viivek46/cassandra:3.11.4

Choose a reason for hiding this comment

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

hm, can we add tooling to use non-personal images? and can we add additional versioning so that we don't overwrite each other's images?

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need to use the Cassandra image, right?

Here's what I propose in terms of KUDO Cassandra depending on the cassandra_exporter repository:

  1. Add cassandra_exporter it as a git submodule under vendor/cassandra_exporter
  2. Create a symlink from images/Dockerfile.prometheus-exporter to vendor/cassandra_exporter/docker/Dockerfile
  3. Build/push mesosphere/cassandra_exporter Docker image based on images/Dockerfile.prometheus-exporter (can be personal for now until I finish implementing Docker image build support) and use that for the prometheus exporter container.
  4. Revert the changes in the Cassandra node Dockerfile and pod.

Choose a reason for hiding this comment

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

This sounds kind of involved - why don't we make this a separate ticket for now so that we don't block the metrics work. If we're okay with personal images for now, let's continue using them until the Docker image build support is in place.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, step 3 above calls out that the image can be personal.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert line 49 for now @viivek46.

Copy link
Contributor Author

@viivek46 viivek46 Oct 25, 2019

Choose a reason for hiding this comment

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

I have modified exporter docker file, as cassandra_exporter.jar file was not accessible by non root user, and i skipped step 1,2 from Murilo's suggestion and copy paste run.sh and docker file from crito's repo and modify them in our repo.

operator/templates/stateful-set.yaml Outdated Show resolved Hide resolved
operator/templates/cassandra-exporter-config-yml.yaml Outdated Show resolved Hide resolved
operator/templates/cassandra-exporter-config-yml.yaml Outdated Show resolved Hide resolved
operator/templates/cassandra-exporter-config-yml.yaml Outdated Show resolved Hide resolved
operator/params.yaml Outdated Show resolved Hide resolved
operator/operator.yaml Show resolved Hide resolved
operator/params.yaml Outdated Show resolved Hide resolved
@@ -46,7 +46,7 @@ spec:
imagePullPolicy: Always
# Dockerfile based on:
# https://github.com/docker-library/cassandra/blob/master/3.11/Dockerfile
image: mpereira/cassandra:3.11.4
image: viivek46/cassandra:3.11.4
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need to use the Cassandra image, right?

Here's what I propose in terms of KUDO Cassandra depending on the cassandra_exporter repository:

  1. Add cassandra_exporter it as a git submodule under vendor/cassandra_exporter
  2. Create a symlink from images/Dockerfile.prometheus-exporter to vendor/cassandra_exporter/docker/Dockerfile
  3. Build/push mesosphere/cassandra_exporter Docker image based on images/Dockerfile.prometheus-exporter (can be personal for now until I finish implementing Docker image build support) and use that for the prometheus exporter container.
  4. Revert the changes in the Cassandra node Dockerfile and pod.

operator/templates/stateful-set.yaml Outdated Show resolved Hide resolved
operator/templates/stateful-set.yaml Outdated Show resolved Hide resolved
resources/service-monitor.yaml Outdated Show resolved Hide resolved
resources/service-monitor.yaml Outdated Show resolved Hide resolved
resources/service-monitor.yaml Outdated Show resolved Hide resolved
@mpereira
Copy link
Contributor

mpereira commented Oct 22, 2019

Hey @viivek46, thanks for your initial work! Changes mostly look good, I left a few comments regarding some changes.

Also, we'll probably want an integration test to make sure this actually works. Maybe we can work on it together? Since I'm still wrapping up #3.

A useful sanity integration test could be similar as the one we have for the DC/OS Cassandra service: https://github.com/mesosphere/dcos-commons/blob/1809d70db5acd6aa8620a82c6a786e3a25d63f89/frameworks/cassandra/tests/test_sanity.py#L85-L104

@mpereira
Copy link
Contributor

Also, I think it's ok that for this PR to not make cassandra_exporter totally configurable through params.yaml. I'll create a separate ticket for that.

@mpereira
Copy link
Contributor

Created https://jira.mesosphere.com/browse/DCOS-60293 for the above.

images/Dockerfile Outdated Show resolved Hide resolved
operator/templates/service.yaml Outdated Show resolved Hide resolved
@@ -46,7 +46,7 @@ spec:
imagePullPolicy: Always
# Dockerfile based on:
# https://github.com/docker-library/cassandra/blob/master/3.11/Dockerfile
image: mpereira/cassandra:3.11.4
image: viivek46/cassandra:3.11.4
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert line 49 for now @viivek46.

docs/README.md Outdated Show resolved Hide resolved

```
kubectl create -f resources/service-monitor.yaml
```
Copy link
Contributor

Choose a reason for hiding this comment

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

We should add instructions to how to import the Grafana dashboard. And probably remove what's currently written, since the service monitor will be installed by default.

Copy link
Contributor Author

@viivek46 viivek46 Oct 25, 2019

Choose a reason for hiding this comment

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

Correct with new changes which include automation I will update this instructions, i just pushed code as "wip" as we were discussing about cassandra_exporter image issue.
Currently I am just updating doc, about adding instructions Grafana dashboard i still need to work out that, as provided json in cassandra_export was not working on my first test.

@mpereira mpereira added the wip label Oct 24, 2019
Co-Authored-By: Murilo Pereira <[email protected]>
@viivek46 viivek46 requested a review from mpereira October 28, 2019 15:55
viivek46 and others added 8 commits October 28, 2019 17:01
* Unify handling of Docker images.

* Build Prometheus exporter Docker image too.

* Set both Docker image namespaces to "mesosphere".

* Make Prometheus exporter image version composite as well.

* Change Prometheus exporter Docker image name.

* Snapshot Docker image versions.

* Improve documentation.

Remove KUDO-specific details.

* Add automatic formatting for Markdown.
Copy link
Contributor

@mpereira mpereira left a comment

Choose a reason for hiding this comment

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

Thanks @viivek46!

@mpereira mpereira merged commit e3ec1e2 into master Oct 30, 2019
@mpereira mpereira deleted the metrics branch October 30, 2019 17:14
@@ -0,0 +1,3 @@
FROM criteord/cassandra_exporter:2.2.1

RUN chown 999:999 /opt/cassandra_exporter/cassandra_exporter.jar
Copy link
Contributor

Choose a reason for hiding this comment

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

@viivek46 can you please explain why we need to chown the file? What runs as UID 999 and why does it need to own this JAR?

Copy link
Contributor

Choose a reason for hiding this comment

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

@porridge: can you please explain why we need to chown the file? What runs as UID 999 and why does it need to own this JAR?

Because of the pod security context this image container runs under.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @mpereira . However chown-ing the file gives the process the permission to modify the code to be run, which is frowned upon from security PoV.
I'm guessing the intent probably to chmod a+r it...

-rw-rwx--- 1 root root 4607224 Jan 30  2019 cassandra_exporter.jar
```
Right. So the fix should actually be done upstream, let me take a stab at it.

Copy link
Contributor

Choose a reason for hiding this comment

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

porridge added a commit that referenced this pull request Feb 19, 2020
The permissions are now [fixed](criteo/cassandra_exporter#68) in upstream repo, so we can drop [the chown](#4 (review)):
```
porridge@beczulka:~$ docker run criteord/cassandra_exporter:2.3.2 ls -l /opt/cassandra_exporter
Unable to find image 'criteord/cassandra_exporter:2.3.2' locally
2.3.2: Pulling from criteord/cassandra_exporter
bc51dd8edc1b: Pull complete 
d1d06863bb82: Pull complete 
adf4d10a782b: Pull complete 
7db4424ff270: Pull complete 
e008a301333c: Pull complete 
10121b885a52: Pull complete 
0d34188e8091: Pull complete 
fc3c7604e1c5: Pull complete 
019737f36353: Pull complete 
a26e5d6f647b: Pull complete 
3b6b59aecfbd: Pull complete 
Digest: sha256:9fe7cfef9b03ca294c80e5da098add4698c4103bbddf382dd93d2e01a073d6e3
Status: Downloaded newer image for criteord/cassandra_exporter:2.3.2
total 4760
-rw-rw-r-- 1 root root 4871483 Feb 10 13:31 cassandra_exporter.jar
porridge@beczulka:~$ 
```
porridge added a commit that referenced this pull request Feb 21, 2020
The permissions are now [fixed](criteo/cassandra_exporter#68) in upstream repo, so we can drop [the chown](#4 (review)):
```
porridge@beczulka:~$ docker run criteord/cassandra_exporter:2.3.2 ls -l /opt/cassandra_exporter
Unable to find image 'criteord/cassandra_exporter:2.3.2' locally
2.3.2: Pulling from criteord/cassandra_exporter
bc51dd8edc1b: Pull complete 
d1d06863bb82: Pull complete 
adf4d10a782b: Pull complete 
7db4424ff270: Pull complete 
e008a301333c: Pull complete 
10121b885a52: Pull complete 
0d34188e8091: Pull complete 
fc3c7604e1c5: Pull complete 
019737f36353: Pull complete 
a26e5d6f647b: Pull complete 
3b6b59aecfbd: Pull complete 
Digest: sha256:9fe7cfef9b03ca294c80e5da098add4698c4103bbddf382dd93d2e01a073d6e3
Status: Downloaded newer image for criteord/cassandra_exporter:2.3.2
total 4760
-rw-rw-r-- 1 root root 4871483 Feb 10 13:31 cassandra_exporter.jar
porridge@beczulka:~$ 
```
porridge added a commit that referenced this pull request Mar 3, 2020
The permissions are now [fixed](criteo/cassandra_exporter#68) in upstream repo, so we can drop [the chown](#4 (review)):
```
porridge@beczulka:~$ docker run criteord/cassandra_exporter:2.3.2 ls -l /opt/cassandra_exporter
Unable to find image 'criteord/cassandra_exporter:2.3.2' locally
2.3.2: Pulling from criteord/cassandra_exporter
bc51dd8edc1b: Pull complete
d1d06863bb82: Pull complete
adf4d10a782b: Pull complete
7db4424ff270: Pull complete
e008a301333c: Pull complete
10121b885a52: Pull complete
0d34188e8091: Pull complete
fc3c7604e1c5: Pull complete
019737f36353: Pull complete
a26e5d6f647b: Pull complete
3b6b59aecfbd: Pull complete
Digest: sha256:9fe7cfef9b03ca294c80e5da098add4698c4103bbddf382dd93d2e01a073d6e3
Status: Downloaded newer image for criteord/cassandra_exporter:2.3.2
total 4760
-rw-rw-r-- 1 root root 4871483 Feb 10 13:31 cassandra_exporter.jar
porridge@beczulka:~$
```
We actually bump to 2.3.3 since the earlier one was non-functional.
porridge added a commit that referenced this pull request Mar 3, 2020
The permissions are now [fixed](criteo/cassandra_exporter#68) in upstream repo, so we can drop [the chown](#4 (review)):
```
porridge@beczulka:~$ docker run criteord/cassandra_exporter:2.3.2 ls -l /opt/cassandra_exporter
Unable to find image 'criteord/cassandra_exporter:2.3.2' locally
2.3.2: Pulling from criteord/cassandra_exporter
bc51dd8edc1b: Pull complete
d1d06863bb82: Pull complete
adf4d10a782b: Pull complete
7db4424ff270: Pull complete
e008a301333c: Pull complete
10121b885a52: Pull complete
0d34188e8091: Pull complete
fc3c7604e1c5: Pull complete
019737f36353: Pull complete
a26e5d6f647b: Pull complete
3b6b59aecfbd: Pull complete
Digest: sha256:9fe7cfef9b03ca294c80e5da098add4698c4103bbddf382dd93d2e01a073d6e3
Status: Downloaded newer image for criteord/cassandra_exporter:2.3.2
total 4760
-rw-rw-r-- 1 root root 4871483 Feb 10 13:31 cassandra_exporter.jar
porridge@beczulka:~$
```

We actually bump to 2.3.3 since the earlier one was non-functional.

Also rename a parameter in cassandra config as the old one is not
recognized.
porridge added a commit that referenced this pull request Mar 3, 2020
The permissions are now [fixed](criteo/cassandra_exporter#68) in upstream repo, so we can drop [the chown](#4 (review)):
```
porridge@beczulka:~$ docker run criteord/cassandra_exporter:2.3.2 ls -l /opt/cassandra_exporter
Unable to find image 'criteord/cassandra_exporter:2.3.2' locally
2.3.2: Pulling from criteord/cassandra_exporter
bc51dd8edc1b: Pull complete
d1d06863bb82: Pull complete
adf4d10a782b: Pull complete
7db4424ff270: Pull complete
e008a301333c: Pull complete
10121b885a52: Pull complete
0d34188e8091: Pull complete
fc3c7604e1c5: Pull complete
019737f36353: Pull complete
a26e5d6f647b: Pull complete
3b6b59aecfbd: Pull complete
Digest: sha256:9fe7cfef9b03ca294c80e5da098add4698c4103bbddf382dd93d2e01a073d6e3
Status: Downloaded newer image for criteord/cassandra_exporter:2.3.2
total 4760
-rw-rw-r-- 1 root root 4871483 Feb 10 13:31 cassandra_exporter.jar
porridge@beczulka:~$
```

We actually bump to 2.3.3 since the earlier one was non-functional.

Also rename a parameter in cassandra config as the old one is not
recognized.
porridge added a commit that referenced this pull request Mar 4, 2020
The permissions are now [fixed](criteo/cassandra_exporter#68) in upstream repo, so we can drop [the chown](#4 (review)):
```
porridge@beczulka:~$ docker run criteord/cassandra_exporter:2.3.2 ls -l /opt/cassandra_exporter
Unable to find image 'criteord/cassandra_exporter:2.3.2' locally
2.3.2: Pulling from criteord/cassandra_exporter
bc51dd8edc1b: Pull complete
d1d06863bb82: Pull complete
adf4d10a782b: Pull complete
7db4424ff270: Pull complete
e008a301333c: Pull complete
10121b885a52: Pull complete
0d34188e8091: Pull complete
fc3c7604e1c5: Pull complete
019737f36353: Pull complete
a26e5d6f647b: Pull complete
3b6b59aecfbd: Pull complete
Digest: sha256:9fe7cfef9b03ca294c80e5da098add4698c4103bbddf382dd93d2e01a073d6e3
Status: Downloaded newer image for criteord/cassandra_exporter:2.3.2
total 4760
-rw-rw-r-- 1 root root 4871483 Feb 10 13:31 cassandra_exporter.jar
porridge@beczulka:~$
```

We actually bump to 2.3.4 since there were other problems with 2.3.2 and 2.3.3.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants