grafana-ansible-collection icon indicating copy to clipboard operation
grafana-ansible-collection copied to clipboard

management of the config.river with the conversion of the config.yaml

Open lbrule opened this issue 1 year ago • 6 comments

This fork will permit to realize a config.river of the flow mode thanks to the config.yaml of the static mode.

The objective is to deploy a grafana agent in mode flow with a dynamic configuration and not only with a config.river already configured before the deployement by ansible.

The solution that i have used it to convert the static format to the flow format is the following command:

  • name: Create Grafana Agent River Config if flow mode for Grafana Agent ansible.builtin.shell: "AGENT_MODE=flow {{ grafana_agent_install_dir }}/grafana-agent convert -f static {{ grafana_agent_config_dir }}/{{ grafana_agent_config_filename }} -o {{ grafana_agent_config_dir }}/{{ grafana_agent_config_filename }}" notify: "restart grafana-agent" when: grafana_agent_provisioned_config_file | length == 0

I have made any tests and it is ok for me

Regards Ludovic

lbrule avatar Feb 12 '24 16:02 lbrule

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Feb 12 '24 16:02 CLAassistant

Hey @lbrule , Thanks for adding this.

Also could you share a snippet of how you would use this in a playbook?

ishanjainn avatar Feb 12 '24 16:02 ishanjainn

/- hosts: all tasks: - name: Install Grafana Agent ansible.builtin.include_role: name: grafana.grafana.grafana_agent vars: grafana_agent_mode: flow # Change config file on the host to .river grafana_agent_config_filename: config.river # Remove default flags grafana_agent_flags_extra: server.http.listen-addr: '0.0.0.0:12345'

lbrule avatar Feb 12 '24 23:02 lbrule

@gardar any thoughts here?

ishanjainn avatar Feb 27 '24 10:02 ishanjainn

Hello @gardar

The config.river is re generated always whene we run again the role. So every time we generate the config.yaml for the static mode and we do a conversion in order to obtain the config.river for the flow mode.

AdminAosCompagny avatar Feb 29 '24 10:02 AdminAosCompagny

@gardar is this okay from your aspect?

ishanjainn avatar Mar 19 '24 08:03 ishanjainn