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

Adding monitoring capability to lvm-operator #49

Merged
merged 3 commits into from
Jan 18, 2022

Conversation

aruniiird
Copy link
Contributor

Signed-off-by: Arun Kumar Mohan amohan@redhat.com

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 24, 2021
@aruniiird aruniiird marked this pull request as draft December 24, 2021 12:59
metadata:
name: controller-manager-metrics-service
rules:
- apiGroups: [""]
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use the same format as the rbac yamls for uniformity.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this require a cluster role?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Initially thought we require a cluster wide permissions, but moved it to Role now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All the yamls are moved to same format

@@ -5,8 +5,8 @@ kind: ServiceMonitor
metadata:
labels:
control-plane: controller-manager
name: controller-manager-metrics-monitor
namespace: system
name: lvm-operator-controller-manager-metrics-monitor
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason for adding the namespace as prefix? if this isn't mandatory for the metrics, can we please not use this?

Copy link
Contributor

Choose a reason for hiding this comment

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

This prefix makes it more readable. In fact, we should add this prefix to all the lvm-operator objects.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

  • this prefix usage was discussed earlier, we decided not to use this and follow ocs-operator convention.
  • the reason was, it's difficult to get this prefix in code where we are associating serviceaccount names with deployments

Copy link
Contributor

Choose a reason for hiding this comment

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

We can modify the kustomize files to include the prefix explicitly. I agree that the prefix should be added.

Copy link
Contributor

Choose a reason for hiding this comment

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

ack, then we need to settle on a consistent name and use that in code as well while supplying serviceaccount names

config/default/kustomization.yaml Outdated Show resolved Hide resolved
@aruniiird aruniiird force-pushed the add-monitoring-components branch 2 times, most recently from 721ac0e to 83799f7 Compare January 11, 2022 02:35
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 11, 2022
@aruniiird aruniiird force-pushed the add-monitoring-components branch from 83799f7 to 51656b8 Compare January 11, 2022 16:49
@aruniiird aruniiird changed the title [WIP] Adding monitoring capability to lvm-operator Adding monitoring capability to lvm-operator Jan 11, 2022
@aruniiird aruniiird force-pushed the add-monitoring-components branch from 51656b8 to bb3ce4e Compare January 12, 2022 05:46
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 12, 2022

func main() {
lvmExpFlags := flag.NewFlagSet("lvm-metrics-exporter", flag.ExitOnError)
lvmExpFlags.StringVar(&exporterNamespace, "namespace", "lvm-exporter",
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is used the namespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently this metric exporter is a dummy one which don't export/expose any particular metrics. Once this is actively used then we require this flag, otherwise this is a place holder

Copy link
Contributor

@nbalacha nbalacha left a comment

Choose a reason for hiding this comment

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

Can a service scrape metrics from both the topolvm and lvm-operator nodes or are separate services required?

config/prometheus/monitor.yaml Outdated Show resolved Hide resolved
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: lvm-operator-controller-metric-rbac-rolebinding
Copy link
Contributor

Choose a reason for hiding this comment

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

Please rename this to lvm-operator-metrics

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: topolvm-metrics
namespace: lvm-operator-system
Copy link
Contributor

Choose a reason for hiding this comment

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

Please set the namespace to system so kustomize can update it correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

config/samples/topolvm-metric-service-config.yaml Outdated Show resolved Hide resolved
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
# 'namespace' is omitted as 'ClusterRole'-s are not namespaced
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this comment as this is a Role, not a ClusterRole.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the comment and added the namespace: system

metadata:
name: controller-manager-metrics-service
rules:
- apiGroups: [""]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this require a cluster role?

config/prometheus/monitor.yaml Show resolved Hide resolved
@aruniiird aruniiird force-pushed the add-monitoring-components branch from bb3ce4e to 52eb1c6 Compare January 12, 2022 15:57
@aruniiird aruniiird marked this pull request as ready for review January 12, 2022 15:57
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 12, 2022
Copy link
Contributor

@sp98 sp98 left a comment

Choose a reason for hiding this comment

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

A couple of questions here:

  • How is the metricsExporter.go getting invoked here?
  • Can the export extract metrics from different components (vgManager, node etc) or just form the operator?

newLogger.Log(log.InfoLevel, "Namespace:", exporterNamespace)
newLogger.Log(log.DebugLevel, "Address:", exporterAddress)

// kubeConfig, err := clientcmd.BuildConfigFromFlags(kubeAPIServerURL, kubeconfigPath)
Copy link
Contributor

Choose a reason for hiding this comment

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

Commented out code can be removed if its not required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the commented out lines

cmd/metricsexporter/metricsExporter.go Outdated Show resolved Hide resolved
cmd/metricsexporter/metricsExporter.go Outdated Show resolved Hide resolved
cmd/metricsexporter/metricsExporter.go Outdated Show resolved Hide resolved
cmd/metricsexporter/metricsExporter.go Outdated Show resolved Hide resolved
cmd/metricsexporter/metricsExporter.go Outdated Show resolved Hide resolved
cmd/metricsexporter/metricsExporter.go Outdated Show resolved Hide resolved
cmd/metricsexporter/metricsExporter.go Outdated Show resolved Hide resolved
http.Handle("/metrics", promhttp.Handler())
http.HandleFunc("/", func(rw http.ResponseWriter, r *http.Request) {
rw.Write([]byte(`<html>
<head><title>LVM Metric Exporter</title></head>
Copy link
Contributor

Choose a reason for hiding this comment

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

(asking for my understanding) Why do we need this HTML ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is added, if user try to access server without /metrics path appended in the address (like 127.0.0.1:8080/).
This will guide them to reach correct location. It is a common practice seen in many metric exporters

.gitignore Outdated Show resolved Hide resolved
@nbalacha
Copy link
Contributor

Please follow the commit lint format for the commit messages :

feat:

Long Description

@aruniiird aruniiird force-pushed the add-monitoring-components branch 4 times, most recently from 39d2f22 to d2f3c90 Compare January 15, 2022 06:19
.vscode/launch.json Outdated Show resolved Hide resolved
Dockerfile.exporter Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
- name: metricsexporter
command:
- /metricsexporter
image: exporter:latest
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this require command line arguments? When I ran a make deploy, the logs show the following:

{"level":"info","ts":1642251710.3554845,"logger":"lvm-metric-exporter","msg":"Exporter set values: ","namespace":"lvm-exporter","address":":23532"}

When the namespace should be lvm-operator-system (default namespace in the kustomize config files)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now it is run on all the default params.
./metricsexporter -h

-address string
        address on which the metrics exporter should run (default ":23532")
  -apiserver string
        API server URL
  -kubeconfig string
        Path to kubeconfig file
  -namespace string
        set the namespace of the lvm metric exporter (default "lvm-exporter")
  -zap-devel
        Development Mode defaults(encoder=consoleEncoder,logLevel=Debug,stackTraceLevel=Warn). Production Mode defaults(encoder=jsonEncoder,logLevel=Info,stackTraceLevel=Error)
  -zap-encoder value
        Zap log encoding (one of 'json' or 'console')
  -zap-log-level value
        Zap Level to configure the verbosity of logging. Can be one of 'debug', 'info', 'error', or any integer value > 0 which corresponds to custom debug levels of increasing verbosity
  -zap-stacktrace-level value
        Zap Level at and above which stacktraces are captured (one of 'info', 'error', 'panic').

Dockerfile.exporter Outdated Show resolved Hide resolved
config/manager/manager.yaml Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
cmd/metricsexporter/metrics_exporter.go Outdated Show resolved Hide resolved
cmd/metricsexporter/metrics_exporter.go Outdated Show resolved Hide resolved
@nbalacha
Copy link
Contributor

Requesting a review from @umangachapagain as he knows monitoring.

@aruniiird aruniiird force-pushed the add-monitoring-components branch from d2f3c90 to c9e9cfd Compare January 17, 2022 07:09
@aruniiird aruniiird force-pushed the add-monitoring-components branch 4 times, most recently from 6c78ec9 to 26a88a0 Compare January 17, 2022 12:49
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 17, 2022
@aruniiird aruniiird force-pushed the add-monitoring-components branch 2 times, most recently from e0f1e92 to e386b7b Compare January 17, 2022 16:19
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 17, 2022
@aruniiird
Copy link
Contributor Author

Something went wrong (completely)... and whole of my changes are gone now.... =(

@leelavg
Copy link
Contributor

leelavg commented Jan 17, 2022

Something went wrong (completely)... and whole of my changes are gone now.... =(

  • Ya, just observed that
  • Maybe use git reflog to checkout at commit e0f1e92 or 26a88a0 (referred from above github commits) if not done already

@aruniiird aruniiird force-pushed the add-monitoring-components branch from e386b7b to 807b805 Compare January 17, 2022 19:01
@leelavg
Copy link
Contributor

leelavg commented Jan 18, 2022

@aruniiird can you please do a rebase?

@aruniiird aruniiird force-pushed the add-monitoring-components branch 2 times, most recently from 3b7c110 to 6dbc39a Compare January 18, 2022 06:25
Signed-off-by: Arun Kumar Mohan <amohan@redhat.com>
As a first step adding all the yaml files needed for the metrics
monitoring.

Signed-off-by: Arun Kumar Mohan <amohan@redhat.com>
@aruniiird aruniiird force-pushed the add-monitoring-components branch 2 times, most recently from 6440622 to f03789c Compare January 18, 2022 07:47
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 18, 2022
@aruniiird aruniiird force-pushed the add-monitoring-components branch from f03789c to 80e5b9a Compare January 18, 2022 08:16
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jan 18, 2022
Signed-off-by: Arun Kumar Mohan <amohan@redhat.com>
Copy link
Contributor

@leelavg leelavg left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 18, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 18, 2022

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: aruniiird, leelavg, sp98

The full list of commands accepted by this bot can be found 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

@nbalacha nbalacha merged commit 52673fa into openshift:main Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants