-
Notifications
You must be signed in to change notification settings - Fork 40
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
Conversation
metadata: | ||
name: controller-manager-metrics-service | ||
rules: | ||
- apiGroups: [""] |
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.
Please use the same format as the rbac yamls for uniformity.
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.
Why does this require a cluster role?
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.
Initially thought we require a cluster wide permissions, but moved it to Role now
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.
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 |
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.
any reason for adding the namespace as prefix? if this isn't mandatory for the metrics, can we please not use 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.
This prefix makes it more readable. In fact, we should add this prefix to all the lvm-operator objects.
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.
Yes, you should add prefix to all your resources.
Use https://github.com/red-hat-storage/lvm-operator/blob/main/config/default/kustomization.yaml#L4-L9 for prefix.
Also, try adding labels via https://github.com/red-hat-storage/lvm-operator/blob/main/config/default/kustomization.yaml#L11-L13 for easy queries later on.
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.
- 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
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 modify the kustomize files to include the prefix explicitly. I agree that the prefix should be added.
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.
ack, then we need to settle on a consistent name and use that in code as well while supplying serviceaccount names
721ac0e
to
83799f7
Compare
83799f7
to
51656b8
Compare
51656b8
to
bb3ce4e
Compare
|
||
func main() { | ||
lvmExpFlags := flag.NewFlagSet("lvm-metrics-exporter", flag.ExitOnError) | ||
lvmExpFlags.StringVar(&exporterNamespace, "namespace", "lvm-exporter", |
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.
Where is used the namespace?
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.
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
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.
Can a service scrape metrics from both the topolvm and lvm-operator nodes or are separate services required?
kind: RoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: lvm-operator-controller-metric-rbac-rolebinding |
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.
Please rename this to lvm-operator-metrics
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.
Done
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: topolvm-metrics | ||
namespace: lvm-operator-system |
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.
Please set the namespace to system so kustomize can update it correctly.
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.
Added
kind: Role | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
# 'namespace' is omitted as 'ClusterRole'-s are not namespaced |
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.
Please remove this comment as this is a Role, not a ClusterRole.
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.
Removed the comment and added the namespace: system
metadata: | ||
name: controller-manager-metrics-service | ||
rules: | ||
- apiGroups: [""] |
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.
Why does this require a cluster role?
bb3ce4e
to
52eb1c6
Compare
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.
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) |
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.
Commented out code can be removed if its not required.
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.
Removed the commented out lines
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> |
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.
(asking for my understanding) Why do we need this HTML ?
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.
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
Please follow the commit lint format for the commit messages : feat: Long Description |
39d2f22
to
d2f3c90
Compare
config/manager/manager.yaml
Outdated
- name: metricsexporter | ||
command: | ||
- /metricsexporter | ||
image: exporter:latest |
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.
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)
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.
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').
Requesting a review from @umangachapagain as he knows monitoring. |
d2f3c90
to
c9e9cfd
Compare
6c78ec9
to
26a88a0
Compare
e0f1e92
to
e386b7b
Compare
Something went wrong (completely)... and whole of my changes are gone now.... =( |
|
e386b7b
to
807b805
Compare
@aruniiird can you please do a rebase? |
3b7c110
to
6dbc39a
Compare
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>
6440622
to
f03789c
Compare
f03789c
to
80e5b9a
Compare
Signed-off-by: Arun Kumar Mohan <amohan@redhat.com>
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.
/lgtm
[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 |
Signed-off-by: Arun Kumar Mohan amohan@redhat.com