Skip to content

Added metrics example to content/client #19

Open

Description

@rbo
$ 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?

Activity

  1. rbo commented on Jan 12, 2023

    @rbo
    MemberAuthor
    {{$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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions