fortigate_exporter icon indicating copy to clipboard operation
fortigate_exporter copied to clipboard

Retrieving the hostname

Open NZMM92 opened this issue 3 years ago • 3 comments

Hello, would it be possible to add a metric to show the hostname of the Fortigate device. Rather than just the IP address of the Fortigate device, and from what I understand that can be retrieved from an existing metric fortigate_version_info.

NZMM92 avatar Oct 28 '22 09:10 NZMM92

Hello, would it be possible to add a metric to show the hostname of the Fortigate device. Rather than just the IP address of the Fortigate device, and from what I understand that can be retrieved from an existing metric fortigate_version_info.

Hi, Having done some research on my own I found out that it is part of the same API as used for this existing metric fortigate_version_info. However the hostname of the Fortigate device is nested under this json object results, as I am not familiar with Go myself would it still be possible to pull information that is nested under an object from a json response?

Thank you in advance for the help NZMM92

NZMM92 avatar Nov 04 '22 08:11 NZMM92

I'm in the same boat since I'm not great with Go. You're correct in that /monitor/system/status returns a hostname: string key-value pair in the json object.

As a workaround I add each target in the prometheus.yml using a hostname instead of IP address:

- job_name: fortigate_exporter
    static_configs:
      - targets:
        - https://my_fortigate_hostname

This does require the hostnames to resolve successfully which can be accomplished multiple ways, either using host settings or by passing hostname:ip_address under extra_hosts in a docker-compose.yml file for example.

The end result is an instance label equal to the hostname of the device, which I can filter in the drop down menu in Grafana.

ether2 avatar Nov 16 '22 18:11 ether2

If you want the hostname attached to all metrics you want to do this in the Prometheus configuration with rewrite rules.

I'm going to keep this issue open as a wish to add hostname to fortigate_version_info

bluecmd avatar Jul 17 '23 11:07 bluecmd