-
Notifications
You must be signed in to change notification settings - Fork 708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bring the textfile collector over from node_exporter #174
Bring the textfile collector over from node_exporter #174
Conversation
I am not sure how to test creating and using the MSI installer, so I am fairly confident that it's not correct. Any tips on how to test this locally would be much appreciated and I can follow up with a PR for the README. |
collector/textfile.go
Outdated
) | ||
|
||
var ( | ||
textFileDirectory = flag.String("collector.textfile.directory", "C:\\Program Files\\prometheus\\textfile_inputs", "Directory to read text files with metrics from.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a sane default?
@@ -27,7 +27,7 @@ type WmiCollector struct { | |||
} | |||
|
|||
const ( | |||
defaultCollectors = "cpu,cs,logical_disk,net,os,service,system" | |||
defaultCollectors = "cpu,cs,logical_disk,net,os,service,system,textfile" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we don't want this as a default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This has been requested quite a few times, so great work implementing it.
There are a couple of things that I think needs some discussion, but in general, seems good!
collector/textfile.go
Outdated
) | ||
|
||
var ( | ||
textFileDirectory = flag.String("collector.textfile.directory", "C:\\Program Files\\prometheus\\textfile_inputs", "Directory to read text files with metrics from.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We default the installation to C:\Program Files\wmi_exporter
so it would be nice to use that, instead of requiring a new directory here.
collector/textfile.go
Outdated
textFileDirectory = flag.String("collector.textfile.directory", "C:\\Program Files\\prometheus\\textfile_inputs", "Directory to read text files with metrics from.") | ||
textFileAddOnce sync.Once | ||
mtimeDesc = prometheus.NewDesc( | ||
"node_textfile_mtime_seconds", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should be putting metrics inside the node
namespace, even ones that are supposed to be compatible? Seems like a dangerous route to go down...
That is, I think this should be wmi_...
instead.
collector/textfile.go
Outdated
buckets, values..., | ||
) | ||
default: | ||
panic("unknown metric type") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this probably comes from the node_exporter code, but should we really panic? I don't like the idea of crashing the exporter just because one of the data sources are bad.
I would prefer just logging this, possibly increasing some diagnostic metric, and then continue
.
collector/textfile.go
Outdated
// Export if there were errors. | ||
ch <- prometheus.MustNewConstMetric( | ||
prometheus.NewDesc( | ||
"node_textfile_scrape_error", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned previously, I don't think this should be in the node
namespace.
collector/textfile_test.go
Outdated
|
||
// Suppress a log message about `nonexistent_path` not existing, this is | ||
// expected and clutters the test output. | ||
log.AddFlags(kingpin.CommandLine) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We haven't switched the wmi_exporter to kingpin for flags yet, so this probably doesn't make sense
collector/textfile_test.go
Outdated
path string | ||
out string | ||
}{ | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these files need to exist for the tests to pass?
README.md
Outdated
@@ -22,6 +22,7 @@ process | [Win32_PerfRawData_PerfProc_Process](https://msdn.microsoft.com/en-us/ | |||
service | [Win32_Service](https://msdn.microsoft.com/en-us/library/aa394418(v=vs.85).aspx) metrics (service states) | ✓ | |||
system | Win32_PerfRawData_PerfOS_System metrics (system calls) | ✓ | |||
tcp | [Win32_PerfRawData_Tcpip_TCPv4](https://msdn.microsoft.com/en-us/library/aa394341(v=vs.85).aspx) metrics (tcp connections) | | |||
textfile | Read prometheus metrics from a text file | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the collector is added to the defaults further down, it should be marked as such here as well (or not be enabled by default)
@@ -39,6 +40,7 @@ Name | Description | |||
`LISTEN_ADDR` | The IP address to bind to. Defaults to 0.0.0.0 | |||
`LISTEN_PORT` | The port to bind to. Defaults to 9182. | |||
`METRICS_PATH` | The path at which to serve metrics. Defaults to `/metrics` | |||
`TEXTFILE_DIR` | As the `--collector.textfile.directory` flag, provide a directory to read text files with metrics from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently should just be one -
, ie -collector.textfile.directory
, since we haven't switched to Kingpin yet
There's a compilation failure in the tests, see here: https://ci.appveyor.com/project/martinlindhe/wmi-exporter/build/402/job/2l6kquvy0c8s6ln7. |
a6975ea
to
d537631
Compare
Regarding the MSI, assuming you have compiled the exporter already, you can build it by running |
56def6c
to
23ca54b
Compare
It looks like wmi_exporter and node_exporter are more different than I had assumed when I just cargo culted this over, so the tests were fairly incompatible with wmi_exporter. This is not ideal, but for now I've removed the tests. |
The MSI that gets built doesn't work - will troubleshoot that. |
I guess the good news is that even if I build the installer from master it still doesn't work, so I am guessing this is a local issue. I'll try to find another wandows computer to test on. |
@carlpett it looks like Here is what the wmi_exporter.wxs file configures the service to use:
Here's what happens when I try that command line flag against the compiled exe:
Any guidance here? |
@poblahblahblah due to powershell parsing arguments with dots in them, you need to specify them like this:
More info in #96 |
@martinlindhe I guess my point is I didn't change anything with the wxs file so it looks like any time i build an MSI with that wxs file the MSI installer fails. Are you building the official packages with a different wxs file? I am pretty confused |
This is an interesting feature! Do you have any examples of where this could be used in a Windows world? Cheers Pete |
@poblahblahblah So sorry for missing this! Due to #169, current master doesn't build working msi:s. I've been pretty busy the last few days, but I'll see if I can fix it today. |
23ca54b
to
b9607e6
Compare
@carlpett no worries! I've updated the wxs file to work correctly. Everything works and my change looks good. |
5956389
to
8c66c64
Compare
@carlpett Any chance this can get a re-review? |
@poblahblahblah Yes, of course! |
collector/textfile.go
Outdated
|
||
var ( | ||
textFileDirectory = flag.String("collector.textfile.directory", "C:\\Program Files\\wmi_exporter\\textfile_inputs", "Directory to read text files with metrics from.") | ||
textFileAddOnce sync.Once |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to be used?
@poblahblahblah The flags PR is now merged! You'll need to
I found an (I think) unused variable in my last pass over this, but apart from that, looks good! |
This adds a slightly modified textfile collector from the official node_exporter project.
8c66c64
to
aea89f1
Compare
aea89f1
to
80002f3
Compare
@carlpett ok - I think this is ready to go. Tested locally and everything worked like expected. edit: To address your comment about the unused variable - that is there to ensure that the textfile gatherer should only be added to the to the gatherer list once. See prometheus/node_exporter#738 |
Great! |
Ah - you are correct. Fix incoming. |
cf5f1b6
to
51470bf
Compare
LGTM! |
Thanks @poblahblahblah! |
…unity#174) Bring the textfile collector over from node_exporter This adds a slightly modified textfile collector from the official node_exporter project.
This adds a slightly modified textfile collector from the official
node_exporter project.