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 initial metrics support #422

Merged
merged 1 commit into from
Apr 27, 2021

Conversation

saschagrunert
Copy link
Member

@saschagrunert saschagrunert commented Apr 27, 2021

What type of PR is this?

/kind feature

What this PR does / why we need it:

This adds the necessary code infrastructure to allow serving metrics
within the operator daemonset (spod). The metrics are for now served
unencrypted on port :8081. An additional service metrics can be used
for scraping from prometheus (by using the auto-discover plugin
kubernetes_sd_configs or a ServiceMonitor together with the
prometheus-operator).

This patch features a sample metric counter
security_profiles_operator_seccomp_profile, which can be distinguished
by the labels update and delete. For example, if we create 4 new
profiles and delete them afterwards, then the output should look like:

\# HELP security_profiles_operator_seccomp_profile Counter about seccomp profile operations.
\# TYPE security_profiles_operator_seccomp_profile counter
security_profiles_operator_seccomp_profile{operation="delete"} 4
security_profiles_operator_seccomp_profile{operation="update"} 4

Things to be done after this patch:

  • decide which metrics we would like to implement
  • provide documentation around the feature
  • add metric related e2e tests

Which issue(s) this PR fixes:

Refers to #276

Does this PR have test?

Yes

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Added `metrics` service endpoint to the operator namespace, which now serves the `security_profiles_operator_seccomp_profile` metric.

This adds the necessary code infrastructure to allow serving metrics
within the operator daemonset (spod). The metrics are for now served
unencrypted on port :8081. An additional service `metrics` can be used
for scraping from prometheus (by using the auto-discover plugin
`kubernetes_sd_configs` or a `ServiceMonitor` together with the
prometheus-operator).

This patch features a sample metric counter
`security_profiles_operator_seccomp_profile`, which can be distinguished
by the labels `update` and `delete`. For example, if we create 4 new
profiles and delete them afterwards, then the output should look like:

```
\# HELP security_profiles_operator_seccomp_profile Counter about seccomp profile operations.
\# TYPE security_profiles_operator_seccomp_profile counter
security_profiles_operator_seccomp_profile{operation="delete"} 4
security_profiles_operator_seccomp_profile{operation="update"} 4
```

Things to be done after this patch:

- decide which metrics we would like to implement
- provide documentation around the feature
- add metric related e2e tests

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 27, 2021
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 27, 2021
@codecov-commenter
Copy link

Codecov Report

Merging #422 (bc9b2cf) into master (e90060e) will increase coverage by 1.69%.
The diff coverage is 73.17%.

@@            Coverage Diff             @@
##           master     #422      +/-   ##
==========================================
+ Coverage   38.00%   39.69%   +1.69%     
==========================================
  Files          20       22       +2     
  Lines         950      985      +35     
==========================================
+ Hits          361      391      +30     
- Misses        574      579       +5     
  Partials       15       15              

Copy link
Contributor

@JAORMX JAORMX left a comment

Choose a reason for hiding this comment

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

yes! This looks like a great start!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 27, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JAORMX, saschagrunert

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit d08ce94 into kubernetes-sigs:master Apr 27, 2021
@saschagrunert saschagrunert deleted the metrics branch April 27, 2021 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants