Skip to content

feat: Add extra_args variables to nvidia_gpu_exporter to support the new per process stats features - #848

Open
Emalios wants to merge 5 commits into
prometheus-community:mainfrom
Emalios:main
Open

feat: Add extra_args variables to nvidia_gpu_exporter to support the new per process stats features#848
Emalios wants to merge 5 commits into
prometheus-community:mainfrom
Emalios:main

Conversation

@Emalios

@Emalios Emalios commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Since version 1.9.0, Nvidia Gpu Exporter allow users to have per process statistics of vram usage.

In order to allow this feature you need to add the argument --collect.compute-apps to the launch command of nvidia_gpu_exporter, so I propose to add a variable extra_args which we can use to activate this option.

I runned the 3 molecules tests, default, latest and alternative. The alternative one needed to up the nvidia_gpu_exporter version cause the feature is only available since 1.9.0

Please do not hesitate to tell me if I did something wrong or if I forgot to do something.

@gardar gardar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR.

We generally try to avoid adding generic extra_args / extra_opts variables to the roles, since we want the supported options to be explicit and tested. Otherwise, it becomes difficult to know which configurations the role actually supports, and the role starts providing less value compared to users passing all command-line arguments themselves.

That said, I have no issue with supporting this specific option. Please add a dedicated variable for --collect.compute-apps instead. Since the feature is only available from version 1.9.0, we should probably guard it with a version check as well.

Please also make sure to add the new option to the role's argument specs, and sign the commits so the DCO check passes.

@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Jul 10, 2026
@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Docs Build 📝

Thank you for contributing!✨

The docs for this PR have been published here:
https://prometheus-community.github.io/ansible/pr/848

You can compare to the docs for the main branch here:
https://prometheus-community.github.io/ansible/branch/main

The docsite for this PR is also available for download as an artifact from this run:
https://github.com/prometheus-community/ansible/actions/runs/30250650854

File changes:

Click to see the diff comparison.

NOTE: only file modifications are shown here. New and deleted files are excluded.
See the file list and check the published docs to see those files.

diff --git a/home/runner/work/ansible/ansible/docsbuild/base/nvidia_gpu_exporter_role.html b/home/runner/work/ansible/ansible/docsbuild/head/nvidia_gpu_exporter_role.html
index 6f6d715..9c62a51 100644
--- a/home/runner/work/ansible/ansible/docsbuild/base/nvidia_gpu_exporter_role.html
+++ b/home/runner/work/ansible/ansible/docsbuild/head/nvidia_gpu_exporter_role.html
@@ -203,6 +203,18 @@ To check whether it is installed, run <code class="code docutils literal notrans
 </div></td>
 </tr>
 <tr class="row-odd"><td><div class="ansible-option-cell">
+<div class="ansibleOptionAnchor" id="parameter-main--nvidia_gpu_exporter_collect_compute_apps"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-nvidia-gpu-exporter-role-parameter-main-nvidia-gpu-exporter-collect-compute-apps"><strong>nvidia_gpu_exporter_collect_compute_apps</strong></p>
+<a class="ansibleOptionLink" href="#parameter-main--nvidia_gpu_exporter_collect_compute_apps" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
+</div></td>
+<td><div class="ansible-option-cell"><p>Enable the --collect.compute-apps flag on the exporter. Requires nvidia_gpu_exporter_version &gt;= 1.9.0.</p>
+<p class="ansible-option-line"><strong class="ansible-option-choices">Choices:</strong></p>
+<ul class="simple">
+<li><p><code class="ansible-option-default-bold docutils literal notranslate"><strong><span class="pre">false</span></strong></code> <span class="ansible-option-choices-default-mark">← (default)</span></p></li>
+<li><p><code class="ansible-option-choices-entry docutils literal notranslate"><span class="pre">true</span></code></p></li>
+</ul>
+</div></td>
+</tr>
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-main--nvidia_gpu_exporter_config_dir"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-nvidia-gpu-exporter-role-parameter-main-nvidia-gpu-exporter-config-dir"><strong>nvidia_gpu_exporter_config_dir</strong></p>
 <a class="ansibleOptionLink" href="#parameter-main--nvidia_gpu_exporter_config_dir" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
@@ -210,7 +222,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-option-default docutils literal notranslate"><span class="pre">&quot;/etc/nvidia_gpu_exporter&quot;</span></code></p>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-main--nvidia_gpu_exporter_local_cache_path"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-nvidia-gpu-exporter-role-parameter-main-nvidia-gpu-exporter-local-cache-path"><strong>nvidia_gpu_exporter_local_cache_path</strong></p>
 <a class="ansibleOptionLink" href="#parameter-main--nvidia_gpu_exporter_local_cache_path" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
@@ -218,7 +230,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-option-default docutils literal notranslate"><span class="pre">&quot;/tmp/nvidia_gpu_exporter-{{</span> <span class="pre">ansible_facts['system']</span> <span class="pre">|</span> <span class="pre">lower</span> <span class="pre">}}-{{</span> <span class="pre">_nvidia_gpu_exporter_go_ansible_arch</span> <span class="pre">}}/{{</span> <span class="pre">nvidia_gpu_exporter_version</span> <span class="pre">}}&quot;</span></code></p>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-main--nvidia_gpu_exporter_system_group"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-nvidia-gpu-exporter-role-parameter-main-nvidia-gpu-exporter-system-group"><strong>nvidia_gpu_exporter_system_group</strong></p>
 <a class="ansibleOptionLink" href="#parameter-main--nvidia_gpu_exporter_system_group" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
@@ -227,7 +239,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-option-default docutils literal notranslate"><span class="pre">&quot;nvidia-gpu-exp&quot;</span></code></p>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-main--nvidia_gpu_exporter_system_user"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-nvidia-gpu-exporter-role-parameter-main-nvidia-gpu-exporter-system-user"><strong>nvidia_gpu_exporter_system_user</strong></p>
 <a class="ansibleOptionLink" href="#parameter-main--nvidia_gpu_exporter_system_user" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
@@ -236,7 +248,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-option-default docutils literal notranslate"><span class="pre">&quot;nvidia-gpu-exp&quot;</span></code></p>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-main--nvidia_gpu_exporter_version"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-nvidia-gpu-exporter-role-parameter-main-nvidia-gpu-exporter-version"><strong>nvidia_gpu_exporter_version</strong></p>
 <a class="ansibleOptionLink" href="#parameter-main--nvidia_gpu_exporter_version" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
@@ -244,7 +256,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-option-default docutils literal notranslate"><span class="pre">&quot;1.10.0&quot;</span></code></p>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-main--nvidia_gpu_exporter_web_listen_address"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-nvidia-gpu-exporter-role-parameter-main-nvidia-gpu-exporter-web-listen-address"><strong>nvidia_gpu_exporter_web_listen_address</strong></p>
 <a class="ansibleOptionLink" href="#parameter-main--nvidia_gpu_exporter_web_listen_address" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
@@ -252,7 +264,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-option-default docutils literal notranslate"><span class="pre">&quot;0.0.0.0:9835&quot;</span></code></p>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-main--nvidia_gpu_exporter_web_telemetry_path"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-nvidia-gpu-exporter-role-parameter-main-nvidia-gpu-exporter-web-telemetry-path"><strong>nvidia_gpu_exporter_web_telemetry_path</strong></p>
 <a class="ansibleOptionLink" href="#parameter-main--nvidia_gpu_exporter_web_telemetry_path" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>

@Emalios

Emalios commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

I changed the extra_args var to an unique boolean which enable the option for the exporter.
I added a guard in the form of a task firstly executed in main.yml, I don't really know if there is a better way to achieve this

@Emalios
Emalios requested a review from gardar July 10, 2026 09:11
@gardar

gardar commented Jul 24, 2026

Copy link
Copy Markdown
Member

I changed the extra_args var to an unique boolean which enable the option for the exporter. I added a guard in the form of a task firstly executed in main.yml, I don't really know if there is a better way to achieve this

That's fine. The other way to do the version check would have been in the template directly but that wouldn't warn users which attempt to use the option on a unsupported version and it would just be ignored silently, so this is actually the preferred way.

Can you please rebase the branch?

Hugo Bergerat added 5 commits July 27, 2026 10:28
…f nvidia_gpu_exporter. Especially to enable the per process gpu vram consuption as detailed [here](utkuozdemir/nvidia_gpu_exporter@43dedb0)

Signed-off-by: Hugo Bergerat <hugo.bergerat@inria.fr>
…nvidia_gpu_exporter as per process gpu stats is only available since version 1.9.0

Signed-off-by: Hugo Bergerat <hugo.bergerat@inria.fr>
…lowing the per process gpu stats

Signed-off-by: Hugo Bergerat <hugo.bergerat@inria.fr>
…ard in main.yml

Signed-off-by: Hugo Bergerat <hugo.bergerat@inria.fr>
Signed-off-by: Hugo Bergerat <hugo.bergerat@inria.fr>
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Jul 27, 2026
@Emalios

Emalios commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Hello, the branch is rebased

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants