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

Added metrics example to content/client #19

Open
rbo opened this issue Jan 12, 2023 · 1 comment
Open

Added metrics example to content/client #19

rbo opened this issue Jan 12, 2023 · 1 comment

Comments

@rbo
Copy link
Collaborator

rbo commented Jan 12, 2023

$ oc adm top pod
NAME                                      CPU(cores)   MEMORY(bytes)   
coe-clair-app-798d5bc956-txkfm            1m           2380Mi          
coe-clair-app-798d5bc956-tzcwn            3m           185Mi           
coe-clair-postgres-79f4bd686c-rrzgs       1901m        11436Mi         
coe-quay-app-bc86bcdb6-bnnvh              58m          3958Mi          
coe-quay-app-bc86bcdb6-vpbrf              24m          4147Mi          
coe-quay-config-editor-68796848ff-t9r4l   0m           63Mi            
coe-quay-database-5b99574df8-cgnkw        11m          164Mi           
coe-quay-mirror-855b4f994-bdgkf           1m           158Mi           
coe-quay-mirror-855b4f994-gpn9b           0m           160Mi           
coe-quay-redis-5fdbc6fdd6-pjj6b           2m           15Mi            
$ oc get pods.metrics
NAME                                      CPU     MEMORY       WINDOW
coe-clair-app-798d5bc956-txkfm            1m      2437748Ki    5m0s
coe-clair-app-798d5bc956-tzcwn            0       190224Ki     5m0s
coe-clair-postgres-79f4bd686c-rrzgs       1901m   11710844Ki   5m0s
coe-quay-app-bc86bcdb6-bnnvh              58m     4053672Ki    5m0s
coe-quay-app-bc86bcdb6-vpbrf              84m     4247680Ki    5m0s
coe-quay-config-editor-68796848ff-t9r4l   0       64560Ki      5m0s
coe-quay-database-5b99574df8-cgnkw        11m     168932Ki     5m0s
coe-quay-mirror-855b4f994-bdgkf           1m      162668Ki     5m0s
coe-quay-mirror-855b4f994-gpn9b           1m      164084Ki     5m0s
coe-quay-redis-5fdbc6fdd6-pjj6b           2m      16252Ki      5m0s

It would be nice to have an go-tempalte for pod.metrics and pod resources with CSV export to get a nice overview. Or combine both on one?

@rbo
Copy link
Collaborator Author

rbo commented Jan 12, 2023

{{$printf_format := "%-25s\t%-25s\t%-25s\t%s\t%-50s\n" }}

{{- printf $printf_format "NAMESPACE" "POD NAME" "CONTAINER NAME" "RESOURCES" "USAGE" -}}
{{- range .items -}}
    {{- if eq .kind "PodMetrics" -}}

        {{$namespace := .metadata.namespace -}}
        {{$pod_name := .metadata.name}}
        {{- range .containers -}}
            {{- if ne .name "POD" -}}
                {{- printf $printf_format $namespace $pod_name .name "-" .usage -}}
            {{- end -}}
        {{- end -}}

    {{- end -}}
    {{- if eq .kind "Pod" -}}
            {{$namespace := .metadata.namespace -}}
            {{$pod_name := .metadata.name}}
        {{- range .spec.containers -}}
            {{$resources := "There are no resources."}}
            {{- if .resources -}}
                {{$resources = .resources }}
            {{- end -}}
            {{- printf $printf_format $namespace $pod_name .name $resources "-" -}}
        {{- end -}}
    {{- end -}}
{{- end -}}

Ugly as hell

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

No branches or pull requests

1 participant