# Modifying victoriametrics configs

**URL:** <https://forums.percona.com/t/modifying-victoriametrics-configs/17437>\
**Category:** PMM 2.x\
**Created:** [September 13, 2022, 1:16pm UTC](https://forums.percona.com/t/modifying-victoriametrics-configs/17437 "2022-09-13T13:16:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Artem\_Timchenko1](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/artem_timchenko1/32/6441_2.png) [@Artem\_Timchenko1](https://forums.percona.com/u/Artem_Timchenko1)\
**Post date:** [September 13, 2022, 1:16pm UTC](https://forums.percona.com/t/modifying-victoriametrics-configs/17437/1 "2022-09-13T13:16:33Z")

</div>

Hi. I use AWS AMI-based installation (PMM version 2.29.1) and I’m looking for some proper and reliable way of modifying underlying pmm-managed victoriametrics config. E.g. I want to modify search.maxSamplesPerQuery property. I can obviously modify /etc/supervisord.d/victoriametrics.ini directly, but I suspect it will be overwritten during update/pmm restart.

---

<div class="post-metadata">

**Author:** ![nurlan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/nurlan/32/1523_2.png) [@nurlan](https://forums.percona.com/u/nurlan)\
**Post date:** [September 13, 2022, 2:48pm UTC](https://forums.percona.com/t/modifying-victoriametrics-configs/17437/2 "2022-09-13T14:48:51Z")

</div>

Hello @Artem_Timchenko1 ,  
you can do it by passing environment variable into our docker container with prefix VM\_. Here you can see how it works [VictoriaMetrics · The High Performance Open Source Time Series Database & Monitoring Solution](https://docs.victoriametrics.com/#environment-variables) for Victoria metrics.

Please let me know if it works for you.

---

<div class="post-metadata">

**Author:** ![Artem\_Timchenko1](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/artem_timchenko1/32/6441_2.png) [@Artem\_Timchenko1](https://forums.percona.com/u/Artem_Timchenko1)\
**Post date:** [September 13, 2022, 2:57pm UTC](https://forums.percona.com/t/modifying-victoriametrics-configs/17437/3 "2022-09-13T14:57:22Z")

</div>

Unfortunately I use AWS AMI, from the [AWS Marketplace](https://docs.percona.com/percona-monitoring-and-management/setting-up/server/aws.html), so no Docker there under the hood.

---

<div class="post-metadata">

**Author:** ![steve.hoffman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/steve.hoffman/32/66_2.png) [@steve.hoffman](https://forums.percona.com/u/steve.hoffman)\
**Post date:** [September 13, 2022, 6:31pm UTC](https://forums.percona.com/t/modifying-victoriametrics-configs/17437/4 "2022-09-13T18:31:04Z")

</div>

Good point but all is not lost! I think you could set the variables globally in /etc/profile.d/victoriametrics.sh (new file)

with `export VM_search_maxSamplesPerQuery=x` as the only line in the file then restart your PMM instance so the variable will be set and VM will read it on next start. (you can do it by hand if you like by running:

```auto
. /etc/profiled.d/victoriametrics.sh
supervisorctl restart victoriametrics

```

but you will need ssh/shell access to your AMI instance.

---

<div class="post-metadata">

**Author:** ![Artem\_Timchenko1](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/artem_timchenko1/32/6441_2.png) [@Artem\_Timchenko1](https://forums.percona.com/u/Artem_Timchenko1)\
**Post date:** [September 15, 2022, 6:54am UTC](https://forums.percona.com/t/modifying-victoriametrics-configs/17437/5 "2022-09-15T06:54:43Z")

</div>

This doesn’t work, most probably due to all the processes being daemons, while /etc/profile.d seems to be used only for login sessions.

I did some tests, will left it here, maybe would be useful for someone.  
The most reliable way is to add these VM\_ variables to `/etc/supervisord.conf`, to `environmant` option in `[supervisord]` section. This will expose these vars to all supervisord-managed services, but it shouldn’t be a big issue. I haven’t found this file to be significantly modified by pmm-update ansible playbook right now.

Another way, which is kind of baggy and hacky is based on a supervisor bag, which allow to merge configurations for programs with the same name. For example, there is a supervisord file to manage VM `/etc/supervisord.d/victoriametrics.ini`, which has program definition `[program:victoriametrics]`. We can create some file like `/etc/supervisord.d/victoriametrics-env.ini` and define the next config there:  
[program:victoriametrics]  
environment = VM\_search\_maxSamplesPerQuery=‘XXX’  
As a result both program definitions will be merged. But as I mentioned, it’s a bug in supervisor which is discussed [here](https://github.com/Supervisor/supervisor/issues/554). Even though it hasn’t been fixed for 7 years already, there is no guarantee things will remain the same 🙂

---

<div class="post-metadata">

**Author:** ![Matthew\_Dennison](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthew_dennison/32/12566_2.png) [@Matthew\_Dennison](https://forums.percona.com/u/Matthew_Dennison)\
**Post date:** [December 20, 2023, 9:19pm UTC](https://forums.percona.com/t/modifying-victoriametrics-configs/17437/6 "2023-12-20T21:19:36Z")

</div>

Is there a ticket on the pmm side to support easier customizations like this one? perhaps maybe mounting in a config file or supporting more env vars?

---

<div class="post-metadata">

**Author:** ![Roma\_Novikov](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/roma_novikov/32/1161_2.png) [@Roma\_Novikov](https://forums.percona.com/u/Roma_Novikov)\
**Post date:** [December 21, 2023, 8:59pm UTC](https://forums.percona.com/t/modifying-victoriametrics-configs/17437/7 "2023-12-21T20:59:16Z")

</div>

@Matthew_Dennison, we are looking to rework the AMI/OVF images to be based on docker/podman inside. So the env vars vill work in this case.  
Will this be a good solution for your case?

---

<div class="post-metadata">

**Author:** ![Matthew\_Dennison](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthew_dennison/32/12566_2.png) [@Matthew\_Dennison](https://forums.percona.com/u/Matthew_Dennison)\
**Post date:** [December 21, 2023, 9:20pm UTC](https://forums.percona.com/t/modifying-victoriametrics-configs/17437/8 "2023-12-21T21:20:27Z")

</div>

Would it be possible to ship this as mult containers as apposed to 1 large container? There are ton of processes inside the container and some update things on the running image. Making it decomposable would allow for more flexibility. An AMI/OVF wouldn’t help the `--search.maxSamplesPerQuery` is defined in the victoriametrics.ini (which is created / written during startup) and cli args take priority over env vars.

> <https://github.com/VictoriaMetrics/VictoriaMetrics/blob/01f9edda64496ff897dfc9f75f4ea0865a5cebdf/lib/envflag/envflag.go#L21>
