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

[Question]: Is it possible to scrape the Result resources through a log aggregator #1348

Open
3 of 4 tasks
abindg opened this issue Dec 13, 2024 · 12 comments
Open
3 of 4 tasks

Comments

@abindg
Copy link

abindg commented Dec 13, 2024

Checklist

  • I've searched for similar issues and couldn't find anything matching
  • I've included steps to reproduce the behavior

Affected Components

  • K8sGPT (CLI)
  • K8sGPT Operator

K8sGPT Version

v0.3.48

Kubernetes Version

1.30.6

Host OS and its Version

No response

Steps to reproduce

  1. When an SRE person sees the result counts on Grafana , instead of logging to k8s and running kubectl get result -n -o json | jq . , is it possible for him to access the solution part of the results in grafana itself through something like loki , which scrapes the results dynamically

Expected behaviour

The SRE should not be required to run through hundreds of results in kubernetes , but see them on grafana

Actual behaviour

The SRE person when he sees the result count in grafana , needs to login and check resuts manually

Additional Information

No response

@AlexsJones
Copy link
Member

@abindg there is a service monitor that exists already for prometheus. This will do exactly what you want.

I will take an action to document this better.

@abindg
Copy link
Author

abindg commented Dec 17, 2024

The default dashboard, shows the count of reaults and the type of results using the service monitor. The contents of the results are not scrapped

@AlexsJones
Copy link
Member

That's quite true, and somewhat intentional, we could emit the results content back into the operator on read, that would let you filter for it in Loki. How does something like that sound?

@abindg
Copy link
Author

abindg commented Dec 19, 2024 via email

@AlexsJones
Copy link
Member

That sounds good. As long as I can get the contents of results on Grafana, and the SRE doesnot need to go through running kubectl desctibe on the results - then we have a strong use case Yahoo Mail: Search, Organize, Conquer On Wed, Dec 18, 2024 at 1:56 AM, Alex @.> wrote: That's quite true, and somewhat intentional, we could emit the results content back into the operator on read, that would let you filter for it in Loki. How does something like that sound? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.>

Okay, I believe my proposal would work. I'd like it to be opt-in functionality though as in the first version of this I think we'd need to be careful about what is exposed through the operator logs.

@AlexsJones
Copy link
Member

how does this fit your need? k8sgpt-ai/k8sgpt-operator#589

@abindg
Copy link
Author

abindg commented Jan 27, 2025

This looks good . How can I test this ?

@AlexsJones
Copy link
Member

I'll get it merged in @abindg

@abindg
Copy link
Author

abindg commented Jan 27, 2025

Ok @AlexsJones . Once merged , then will there be a change in the helm chart ? As far as I understand with this change we can get the Solutions part of the Results into the operator logs . The result name will not be spit out . Is this understanding correct ? Then we can scrape the logs of operator .

@AlexsJones
Copy link
Member

Ok @AlexsJones . Once merged , then will there be a change in the helm chart ? As far as I understand with this change we can get the Solutions part of the Results into the operator logs . The result name will not be spit out . Is this understanding correct ? Then we can scrape the logs of operator .

You will just need to do a helm repo update and then reinstall the new chart.. about to cut the release shortly

@abindg
Copy link
Author

abindg commented Jan 29, 2025

Ok @AlexsJones . Once merged , then will there be a change in the helm chart ? As far as I understand with this change we can get the Solutions part of the Results into the operator logs . The result name will not be spit out . Is this understanding correct ? Then we can scrape the logs of operator .

You will just need to do a helm repo update and then reinstall the new chart.. about to cut the release shortly

Hi @AlexsJones After installing the new version , the logs are not spitting out the results it was supposed to please find the screen shots below:

Image

Image

Am I missing something ? I installed using -> helm upgrade --install k8sgpt k8sgpt/k8sgpt-operator -n k8sgpt-operator-system --create-namespace --set serviceMonitor.enabled=true --set serviceMonitor.additionalLabels.release=prometheus --set grafanaDashboard.enabled=true

@abindg
Copy link
Author

abindg commented Jan 30, 2025

The helm chart needs to be updated to roll this out . The flag --enable-result-logging needs to be set for controllerManager container . And the value needs to be made dynamic through helm . These are not done . I have made the changes locally and it works now .

Image

The Deployment change:

  • args:
    - --health-probe-bind-address=:8081
    - --metrics-bind-address=127.0.0.1:8080
    - --leader-elect
    - --enable-result-logging={{ .Values.controllerManager.manager.enableResultLogging | default "false" }} # Added the argument to enable result logging
    command:
    - /manager
    env:
    - name: KUBERNETES_CLUSTER_DOMAIN
    value: {{ quote .Values.kubernetesClusterDomain }}
    - name: OPERATOR_SINK_WEBHOOK_TIMEOUT_SECONDS
    value: {{ quote .Values.controllerManager.manager.sinkWebhookTimeout }}
    image: {{ .Values.controllerManager.manager.image.repository }}:{{ .Values.controllerManager.manager.image.tag
    | default .Chart.AppVersion }}

Correspoding values.yaml change:

manager:
# Add the enableResultLogging variable here, which can be toggled in values.yaml
enableResultLogging: true # This is now configurable in the values.yaml file

I can give a PR . What do you think @AlexsJones

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Proposed
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants