zabbix-community / helm-zabbix

Helm chart for Zabbix
https://artifacthub.io/packages/helm/zabbix-community/zabbix
Apache License 2.0
83 stars 48 forks source link

[zabbix-community/zabbix] Agent 2 Plugin Configuration of Plugin Options #22

Closed MaxDiOrio closed 7 months ago

MaxDiOrio commented 1 year ago

There doesn't seem to be a way to modify the plugin configuration options in the helm chart. There are no helm values exposed, and no way to mount configmaps into the container.

E.g.: I am attempting to use the Postgres plugin to monitor a database. I want to use a custom query, however there is no default value set for Plugins.Postgres.CustomQueriesPath, and no way to adjust the path when the agent is deployed using the Helm chart that I can see.

aeciopires commented 1 year ago

Hello @MaxDiOrio !

Thanks for your question.

According to these documentation links... I understood that the Plugins.Postgres.CustomQueriesPath parameter is a setting from the zabbix_agent2.conf file, right?

Therefore, you can use the following helm values ​​to add custom settings on the agent and mount a file in the pod. Creating the configmap to mount can be accomplished using the Kubernetes yaml manifest or the kubectl command.

# **Zabbix Agent** configurations
zabbixagent:
  # -- Enables use of **Zabbix Agent**
  enabled: true
  # -- Extra environment variables. A list of additional environment variables. See example: https://github.com/zabbix-community/helm-zabbix/blob/master/charts/zabbix/docs/example/kind/values.yaml
  extraEnv: []
  # -- additional volumeMounts to the zabbix agent container
  extraVolumeMounts: []

Your need is an advanced configuration and we understand that you must have knowledge to execute.

References:

Zabbix-Agent2

Postgresql

Extraenv

Extraparameters

sa-ChristianAnton commented 1 year ago

I think the solution should be easy, without having to override the entire zabbix-agent2.conf, as since Zabbix 6.0 it is possible to phase out Plugins configuration options to Included config file snippets, as with all other configuration settings. This was not possible for Plugin..... settings before 6.0.

The entrypoint of the zabbix-agent2 image does even have a directory prepared for that: /etc/zabbix/zabbix_agent2.d/plugins.d/*.conf: https://github.com/zabbix/zabbix-docker/blob/35d3837b0d5ad6a1c1d9b435734550115a867955/Dockerfiles/agent2/alpine/docker-entrypoint.sh#L183

So, a working solution could look as follows (untested):

kind: ConfigMap
apiVersion: v1
metadata:
  name: postgresql-agent2-config
data:
  postgresql.conf: |
    Plugins.Postgres.CustomQueriesPath=/etc/zabbix/postgres/sql

You can then define an extraVolume from within the "zabbixserver" or "zabbixproxy" section of the values.yaml:

zabbixserver:
  extraVolumes:
    - name: agent-postgres-config
      configMap:
        name: postgresql-agent2-config

This will be changed if #20 gets implemented as commented by me, then you would have to put the above into the zabbixagent section.

And then you can mount this volume inside the Zabbix Agent2 container with the following in your values.yaml:

zabbixagent:
  extraVolumeMounts:
    - name: agent-postgres-config
      mountPath: /etc/zabbix/zabbix_agent2.d/plugins.d

Together with #20 we might set a templating in values.yaml to build these configmaps and mount them into the agent container, like this:

zabbixagent:
  extraAgentPluginConfigs:
    - fileName: postgres.conf
      content: |
        Plugins.Postgres.CustomQueriesPath=/some/path

But this is not implemented yet.

Can we close this issue then?

aeciopires commented 7 months ago

Closing this issue because passed a one year without feedback. You can reopen if necessary.