This repository was archived by the owner on Jul 28, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 513
Windows exporter integration #475
Merged
mattdurham
merged 37 commits into
grafana-cold-storage:main
from
mattdurham:windows_exporter_integration
Mar 25, 2021
Merged
Changes from 6 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
5ce84f4
Merge pull request #1 from grafana/master
mattdurham 876a0fb
Merge remote-tracking branch 'upstream/main'
mattdurham f41be56
Testing
mattdurham f632cf0
Merge remote-tracking branch 'upstream/main' into windows_exporter_in…
mattdurham 1121a04
Windows Exporter support
mattdurham 0951007
Add untracked files
mattdurham fdd16d1
Checkin example converting to custom config
mattdurham 477c312
Merge remote-tracking branch 'upstream/main' into windows_exporter_in…
mattdurham 3ec74d4
Scary reflect for getting the values
mattdurham 67741ff
Smaller item feedback in PR
mattdurham 3bdd395
Add linting exception
mattdurham 2a78895
Update the changelog
mattdurham 871a634
Fix MSSQL config
mattdurham 022e718
Reorder functions and fix comments.
mattdurham 59af5d8
Clean up var names
mattdurham 51e17d5
Change to explicit setting of map
mattdurham 106a443
minor formatting
mattdurham 4dce453
Switch to explicit mapping
mattdurham 0e10fd3
Add some checks on sync
mattdurham 94d035b
Use far simpler method, under the assumption an empty string is not a…
mattdurham 21c6ba5
Use far simpler method, under the assumption an empty string is not a…
mattdurham 7d8427b
Add vendor files
mattdurham 7cd5999
Add build tags so windows specific items dont get included
mattdurham 80adb50
Fix linting error
mattdurham 54d60b6
Merge pull request #4 from mattdurham/Explicit_Mapping
mattdurham 49b0b66
Fix linting error
mattdurham 1c61fc6
Fix linting error
mattdurham cc2d8bb
Fix linting error
mattdurham 536d583
Fix linting error
mattdurham 27423ec
Update CHANGELOG.md
mattdurham 13eceb9
PR feedback of cleaning vars
mattdurham d4dd9fd
Merge remote-tracking branch 'origin/windows_exporter_integration' in…
mattdurham b1dd32e
Merge remote-tracking branch 'upstream/main' into windows_exporter_in…
mattdurham 0ff7721
Rearranging files for non windows usage.
mattdurham d468deb
Cross platform support
mattdurham 4b1b8fd
Cross platform support
mattdurham 6bb695f
Add beta verbiage
mattdurham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| // +build windows | ||
|
|
||
| package install | ||
|
|
||
| import _ "github.com/grafana/agent/pkg/integrations/windows_exporter" // register windows_exporter | ||
|
mattdurham marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // +build windows | ||
|
mattdurham marked this conversation as resolved.
Outdated
|
||
|
|
||
| package windows_exporter //nolint:golint | ||
|
|
||
| import ( | ||
| "github.com/go-kit/kit/log" | ||
| "github.com/grafana/agent/pkg/integrations" | ||
| "github.com/grafana/agent/pkg/integrations/config" | ||
| ) | ||
|
|
||
| // Config controls the node_exporter integration. | ||
| type Config struct { | ||
| Common config.Common `yaml:",inline"` | ||
|
|
||
| WindowsConfig interface{} `yaml:"config"` | ||
|
|
||
| EnabledCollectors string `yaml:"enabledCollectors"` | ||
|
rfratto marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| // UnmarshalYAML implements yaml.Unmarshaler for Config. | ||
| func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { | ||
| type plain Config | ||
| return unmarshal((*plain)(c)) | ||
| } | ||
|
|
||
| func (c *Config) Name() string { | ||
| return "windows_exporter" | ||
| } | ||
|
|
||
| func (c *Config) CommonConfig() config.Common { | ||
| return c.Common | ||
| } | ||
|
|
||
| func (c *Config) NewIntegration(l log.Logger) (integrations.Integration, error) { | ||
| return New(l, c) | ||
| } | ||
|
|
||
| func init() { | ||
| integrations.RegisterIntegration(&Config{}) | ||
| } | ||
|
mattdurham marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| // +build windows | ||
|
|
||
| package windows_exporter //nolint:golint | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "net/http" | ||
|
|
||
| "gopkg.in/yaml.v2" | ||
|
|
||
| "github.com/go-kit/kit/log" | ||
| "github.com/go-kit/kit/log/level" | ||
| "github.com/gorilla/mux" | ||
| "github.com/grafana/agent/pkg/integrations/config" | ||
| "github.com/prometheus-community/windows_exporter/exporter" | ||
| "github.com/prometheus/client_golang/prometheus" | ||
| "github.com/prometheus/client_golang/prometheus/promhttp" | ||
| ) | ||
|
|
||
| type Integration struct { | ||
| c *Config | ||
| logger log.Logger | ||
| wc *exporter.WindowsCollector | ||
|
|
||
| exporterMetricsRegistry *prometheus.Registry | ||
| } | ||
|
|
||
| // New creates a new node_exporter integration. | ||
| func New(log log.Logger, c *Config) (*Integration, error) { | ||
|
|
||
| bytes, _ := yaml.Marshal(c.WindowsConfig) | ||
|
mattdurham marked this conversation as resolved.
Outdated
|
||
| cb := string(bytes) | ||
| wc, _ := exporter.NewWindowsCollector(c.Name(), c.EnabledCollectors, cb) | ||
|
mattdurham marked this conversation as resolved.
Outdated
|
||
|
|
||
| level.Info(log).Log("msg", "Enabled windows_exporter collectors") | ||
|
|
||
| return &Integration{ | ||
|
mattdurham marked this conversation as resolved.
Outdated
|
||
| c: c, | ||
| logger: log, | ||
| wc: wc, | ||
|
|
||
| exporterMetricsRegistry: prometheus.NewRegistry(), | ||
| }, nil | ||
| } | ||
|
|
||
| // RegisterRoutes satisfies Integration.RegisterRoutes. The mux.Router provided | ||
| // here is expected to be a subrouter, where all registered paths will be | ||
| // registered within that subroute. | ||
| func (i *Integration) RegisterRoutes(r *mux.Router) error { | ||
| handler, err := i.handler() | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| r.Handle("/metrics", handler) | ||
| return nil | ||
| } | ||
|
|
||
| func (i *Integration) handler() (http.Handler, error) { | ||
| r := prometheus.NewRegistry() | ||
| if err := r.Register(i.wc); err != nil { | ||
| return nil, fmt.Errorf("couldn't register windows_exporter collector: %w", err) | ||
| } | ||
| handler := promhttp.HandlerFor( | ||
| prometheus.Gatherers{i.exporterMetricsRegistry, r}, | ||
| promhttp.HandlerOpts{ | ||
| ErrorHandling: promhttp.ContinueOnError, | ||
| MaxRequestsInFlight: 0, | ||
| Registry: i.exporterMetricsRegistry, | ||
| }, | ||
| ) | ||
|
|
||
| return handler, nil | ||
| } | ||
|
|
||
| // ScrapeConfigs satisfies Integration.ScrapeConfigs. | ||
| func (i *Integration) ScrapeConfigs() []config.ScrapeConfig { | ||
| return []config.ScrapeConfig{{ | ||
| JobName: i.c.Name(), | ||
| MetricsPath: "/metrics", | ||
| }} | ||
| } | ||
|
|
||
| // Run satisfies Integration.Run. | ||
| func (i *Integration) Run(ctx context.Context) error { | ||
| // We don't need to do anything here, so we can just wait for the context to | ||
| // finish. | ||
| <-ctx.Done() | ||
| return ctx.Err() | ||
| } | ||
1 change: 1 addition & 0 deletions
1
vendor/github.com/Microsoft/hcsshim/.gitignore
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
vendor/github.com/Microsoft/hcsshim/.gometalinter.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
vendor/github.com/Microsoft/hcsshim/LICENSE
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
vendor/github.com/Microsoft/hcsshim/README.md
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
vendor/github.com/Microsoft/hcsshim/appveyor.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.