Skip to content

🌱 Promtail to alloy migration #11945

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

irapandey
Copy link
Contributor

What this PR does / why we need it:
This PR is to migrate from promtail to alloy

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #
#11881

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 10, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign enxebre for approval. For more information see the Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added do-not-merge/needs-area PR is missing an area label needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 10, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @irapandey. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 10, 2025
@irapandey irapandey changed the title Promtail to alloy migration 🌱 Promtail to alloy migration Mar 10, 2025
@irapandey
Copy link
Contributor Author

Screenshot 2025-03-10 at 3 09 48 PM

@irapandey
Copy link
Contributor Author

Hey @chrischdi

I have opened this PR for promtail/alloy migration
Please take a look here.

Thanks 😄

@chrischdi
Copy link
Member

/ok-to-test

/area devtools

Can you also check grafana if you're able to query logs?

@k8s-ci-robot k8s-ci-robot added area/devtools Issues or PRs related to devtools ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. do-not-merge/needs-area PR is missing an area label labels Mar 13, 2025
@@ -1,5 +1,3 @@
# Configuration for promtail chart, see https://github.com/grafana/helm-charts/tree/main/charts/promtail
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add the right link for alloy?

Copy link
Member

@chrischdi chrischdi Mar 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❯ helm show chart grafana/alloy
apiVersion: v2
appVersion: v1.7.2
dependencies:
- condition: crds.create
  name: crds
  repository: ""
  version: 0.0.0
description: Grafana Alloy
icon: https://raw.githubusercontent.com/grafana/alloy/main/docs/sources/assets/alloy_icon_orange.svg
name: alloy
type: application
version: 0.12.3

@@ -1,5 +1,3 @@
# Configuration for promtail chart, see https://github.com/grafana/helm-charts/tree/main/charts/promtail

config:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure we have to change things here as its a different helm chart.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find dedicated charts for alloy like for promtail - https://grafana.com/docs/alloy/latest/set-up/install/kubernetes/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

helm show values grafana/alloy does not even have a config field.

So all configuration below would be not used (and we want them to work).

So I'm curious if this even shows us logs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This page maybe helps: https://grafana.com/docs/alloy/latest/set-up/migrate/from-promtail/

Note: the values.yaml is not the promtail configuration.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should get the promtail.yaml via: kustomize build --enable-helm --load-restrictor LoadRestrictionsNone hack/observability/promtail | grep stringData -A 38 | yq '.stringData[]' > promtail.yaml

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me take a look and get back - I kinda had the same feeling but needed some input
Thanks 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for being MIA

I believe since Alloy used .alloy files to run - we simply add the converted promtail config to ./alloy dir and run alloy using this file

I commiting the file so you can review

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 15, 2025
@chrischdi
Copy link
Member

I ran tilt-up and accessed grafana.

I'm not able to see any logs so looks like alloy does not work in that configuration which is currently on the PR.

image

@@ -1,5 +1,4 @@
# Configuration for promtail chart, see https://github.com/grafana/helm-charts/tree/main/charts/promtail

# Configuration for alloy - https://github.com/grafana/alloy/blob/main/operations/helm/charts/alloy/values.yaml
config:
Copy link
Member

@chrischdi chrischdi Apr 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to replace the file with this content:

# Configuration for alloy - https://github.com/grafana/alloy/blob/main/operations/helm/charts/alloy/values.yaml

alloy:
  configMap:
    create: true
    name: alloy-config
    key: config.alloy
  mounts:
    varlog: true

@chrischdi
Copy link
Member

Let's have these two changes, then please check in grafana if we get logs.

After that works we can start to verify that the new config has the same effect as the previous promtail config.

@irapandey irapandey force-pushed the promtail-to-alloy-migration branch from 0aefd45 to bfdcc7a Compare April 26, 2025 19:33
@irapandey
Copy link
Contributor Author

Screenshot 2025-04-27 at 1 02 47 AM

@irapandey
Copy link
Contributor Author

Hey @chrischdi

I made those changes and didn't see any logs - Added a configmap separately and got logs

I tried creating it from the ./alloy/values.yaml but it didn't see to create what we were expecting

Hope this works

Thanks

Comment on lines 2 to 36
# config:
# # publish data to loki
# clients:
# - url: http://loki:3100/loki/api/v1/push
# # We have to set the tenant_id/OrgID to push logs to Loki
# # otherwise we get an auth error.
# tenant_id: 1

# snippets:
# pipelineStages:
# # Parse cluster and machine to make them available as labels.
# - cri: {}
# - json:
# expressions:
# controller:
# Cluster: join('/',[Cluster.namespace,Cluster.name])
# Machine: join('/',[Machine.namespace,Machine.name])
# KubeadmControlPlane: join('/',[KubeadmControlPlane.namespace,KubeadmControlPlane.name])
# MachineDeployment: join('/',[MachineDeployment.namespace,MachineDeployment.name])
# MachineSet: join('/',[MachineSet.namespace,MachineSet.name])
# MachinePool: join('/',[MachinePool.namespace,MachinePool.name])
# - labels:
# controller:
# Cluster:
# Machine:
# KubeadmControlPlane:
# MachineDeployment:
# MachineSet:
# MachinePool:


# Add a yaml file to generate



Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# config:
# # publish data to loki
# clients:
# - url: http://loki:3100/loki/api/v1/push
# # We have to set the tenant_id/OrgID to push logs to Loki
# # otherwise we get an auth error.
# tenant_id: 1
# snippets:
# pipelineStages:
# # Parse cluster and machine to make them available as labels.
# - cri: {}
# - json:
# expressions:
# controller:
# Cluster: join('/',[Cluster.namespace,Cluster.name])
# Machine: join('/',[Machine.namespace,Machine.name])
# KubeadmControlPlane: join('/',[KubeadmControlPlane.namespace,KubeadmControlPlane.name])
# MachineDeployment: join('/',[MachineDeployment.namespace,MachineDeployment.name])
# MachineSet: join('/',[MachineSet.namespace,MachineSet.name])
# MachinePool: join('/',[MachinePool.namespace,MachinePool.name])
# - labels:
# controller:
# Cluster:
# Machine:
# KubeadmControlPlane:
# MachineDeployment:
# MachineSet:
# MachinePool:
# Add a yaml file to generate

@@ -1,13 +1,16 @@
resources:
- ../namespace.yaml
- alloy-config.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's still use the other approach so we would get a new configmap on config changes + auto-recreation of the pods.

Suggested change
- alloy-config.yaml

And below add

configMapGenerator:
- name: alloy-config
  files:
  - config.alloy

Comment on lines 1 to 7
apiVersion: v1
kind: ConfigMap
metadata:
name: alloy-config
namespace: observability
data:
config.alloy: |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this stuff and rename the file to config.alloy

@chrischdi
Copy link
Member

Hey @chrischdi

I made those changes and didn't see any logs - Added a configmap separately and got logs

I tried creating it from the ./alloy/values.yaml but it didn't see to create what we were expecting

Hope this works

Thanks

Let's try this again, this should normally work :-) Let me know if you need help on it.

@irapandey
Copy link
Contributor Author

Sure - now that I know where the problem was - this will be a easier fix

@irapandey irapandey force-pushed the promtail-to-alloy-migration branch from 269b5d7 to 3d54610 Compare May 20, 2025 11:47
@irapandey irapandey force-pushed the promtail-to-alloy-migration branch from 3d54610 to 861ed75 Compare May 20, 2025 13:27
@irapandey
Copy link
Contributor Author

Hey @chrischdi - I might be missing something here for sure

I have been referring to this file for values.yaml that are used by the alloy helm chart - https://github.com/grafana/alloy/blob/main/operations/helm/charts/alloy/values.yaml

## Various Alloy settings. For backwards compatibility with the grafana-agent
## chart, this field may also be called "agent". Naming this field "agent" is
## deprecated and will be removed in a future release.
alloy:
  configMap:
    # -- Create a new ConfigMap for the config file.
    create: true
    # -- Content to assign to the new ConfigMap.  This is passed into `tpl` allowing for templating from values.
    content: ''

    # -- Name of existing ConfigMap to use. Used when create is false.
    name: null
    # -- Key in ConfigMap to get config from.
    key: null

Looking at this above - I have been trying to generate a configmap with the name alloy-config, based on the comments in the code above

qq - do we want to use alloy.config to generate the configmap or adding alloy.config.content would suffice

Screenshot 2025-05-20 at 6 56 38 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/devtools Issues or PRs related to devtools cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants