windows_exporter icon indicating copy to clipboard operation
windows_exporter copied to clipboard

An error has occurred while serving metrics

Open fabricesemti80 opened this issue 2 years ago • 3 comments

Hello,

I have deployed version 0.23.1 (and latter 0.24.0) to a number of Windows hosts (some of the new deployments are Windows Server 2016...I am aware these are running out of support soon, but due to business needs we had to deploy some recently).

The installation was done using https://github.com/DanielWeeber/ansible-role-windows_exporter . (I am aware that this is a 3rd party role, but the installer worked well to most - near 300 - servers, and the log / health check is all state that installation of the exporter was a-OK.)

For refrerence my parameters were: version: '0.24.0' collectors: ENABLED_COLLECTORS="ad,cache,cpu,cpu_info,cs,iis,logical_disk,memory,net,os,process,service,system,tcp,time"

Checking a host with problems:

Clear-host
$server = 'dc1modftb04p.<domain>'

Write-Host "Prometheus status on $server :" -ForegroundColor Yellow
((Invoke-WebRequest -Uri "http://$($server):9182/health").content | ConvertFrom-Json).Status

# Prometheus status on dc1modftb04p.<domain> :
# ok

then

Write-Host "Prometheus version on $server :" -ForegroundColor Yellow
(Invoke-WebRequest -Uri "http://$($server):9182/version").content | ConvertFrom-Json

Prometheus version on dc1modftb04p.<domain> :


# version   : 0.24.0
# revision  : 5e7462a70e19cc1147cb930a61982897413b9120
# branch    : heads/tags/v0.24.0
# buildUser : runneradmin@fv-az282-478
# buildDate : 20230926-08:57:56
# goVersion : go1.21.1

But here is my problem:

Write-Host "Prometheus metrics on $server :" -ForegroundColor Yellow
Invoke-WebRequest -Uri "http://$($server):9182/metrics"

# Prometheus metrics on dc1modftb04p.<domain> :
# Invoke-WebRequest : An error has occurred while serving metrics: error collecting metric Desc{fqName: # "windows_exporter_collector_success", help: "windows_exporter: Whether the collector was successful.", constLabels: {}, variableLabels: # [{collector }]}: 
# failed to prepare scrape: EOF
# At line:2 char:1
# + Invoke-WebRequest -Uri "http://$($server):9182/metrics"
# + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#     + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
#     + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

What am I missing? And more importantly: how to rectify?

fabricesemti80 avatar Nov 01 '23 17:11 fabricesemti80

For clarification, issue is happening both with latest and latest -1 release. Ansible gives all thumbs-up with both, but no metrics image image

fabricesemti80 avatar Nov 01 '23 17:11 fabricesemti80

Same here, but found the solution. I've run windows_exporter.exe manually with log.file mylogfile.txt in order to diagnose. Actually, you cannot enable modules that the machine doesn't have. Eg, I had mssql and iis modules enabled.

I'm currently working on a script to detect ad / dns / mssql / iis in order to enable collectors only when necessary. I just uploaded my initial work at https://github.com/netinvent/windows_exporter_installer Contribs are welcome ;)

deajan avatar Nov 14 '23 17:11 deajan

This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

github-actions[bot] avatar Feb 13 '24 02:02 github-actions[bot]