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

Custom resources spam Info metric %s does not have _info suffix #2155

Closed
chrischdi opened this issue Aug 18, 2023 · 2 comments · Fixed by #2157
Closed

Custom resources spam Info metric %s does not have _info suffix #2155

chrischdi opened this issue Aug 18, 2023 · 2 comments · Fixed by #2157
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@chrischdi
Copy link
Member

What happened:

I configured a custom resource metric with the following configuration:

kind: CustomResourceStateMetrics
spec:
  resources:
  - groupVersionKind:
      group: cluster.x-k8s.io
      kind: Machine
      version: v1beta1
    - name: owner
      help: Owner references.
      each:
        info:
          labelsFromPath:
            owner_is_controller:
            - controller
            owner_kind:
            - kind
            owner_name:
            - name
            owner_uid:
            - uid
          path:
          - metadata
          - ownerReferences
        type: Info

KSM spams the following message on every CR creation:

I0818 16:54:32.105070   71540 generator.go:79] "Info metric %s does not have _info suffix" capi_machine_owner="(MISSING)"

This is caused here:

klog.InfoS("Info metric %s does not have _info suffix", family.Name)

What you expected to happen:

  • The message only getting printed out a single time on startup instead of on every CR creation
  • The message either using Infof or properly using InfoS, e.g. klog.InfoS("Info metric does not have _info suffix", "family.Name", family.Name)

How to reproduce it (as minimally and precisely as possible):

Use the above configuration and adjust to any kind of custom resource (because all provide the .metadata.ownerReferences property)

Anything else we need to know?:

Environment:

  • kube-state-metrics version: main
  • Kubernetes version (use kubectl version): v1.27.3
  • Cloud provider or hardware configuration: kind
  • Other info:
@chrischdi chrischdi added the kind/bug Categorizes issue or PR as related to a bug. label Aug 18, 2023
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Aug 18, 2023
@mrueg
Copy link
Member

mrueg commented Aug 18, 2023

/triage accepted

klog.InfoS("Info metric does not have _info suffix", "family.Name", family.Name) sounds like a good approach.

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 18, 2023
@chrischdi
Copy link
Member Author

We could move the name validation and log output somewhere into registry_factory instead, e.g. when doing compileFamily or newCompiledMetric:

func compileFamily(f Generator, resource Resource) (*compiledFamily, error) {
labels := resource.Labels.Merge(f.Labels)
metric, err := newCompiledMetric(f.Each)
if err != nil {
return nil, fmt.Errorf("compiling metric: %w", err)
}
labelsFromPath, err := compilePaths(labels.LabelsFromPath)
if err != nil {
return nil, fmt.Errorf("labelsFromPath: %w", err)
}
errorLogV := f.ErrorLogV
if errorLogV == 0 {
errorLogV = resource.ErrorLogV
}
return &compiledFamily{
Name: fullName(resource, f),
ErrorLogV: errorLogV,
Help: f.Help,
Each: metric,
Labels: labels.CommonLabels,
LabelFromPath: labelsFromPath,
}, nil
}

@chrischdi chrischdi changed the title Custom resources spam Info metric %s does not have _info suffix for metrics similar to core APIs Custom resources spam `Info metric %s does not have _info suffix Aug 18, 2023
@chrischdi chrischdi changed the title Custom resources spam `Info metric %s does not have _info suffix Custom resources spam Info metric %s does not have _info suffix Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
3 participants