Skip to content

Commit

Permalink
Add new cmd and config option to set node exporter target
Browse files Browse the repository at this point in the history
  • Loading branch information
arbulu89 committed Nov 27, 2024
1 parent 8ab2c9f commit 01b8f40
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,16 @@ func LoadConfig(fileSystem afero.Fs) (*agent.Config, error) {
DiscoveriesPeriodsConfig: discoveryPeriodsConfig,
}

prometheusTargets := discovery.PrometheusTargets{
discovery.NodeExporterName: viper.GetString("node-exporter-target"),
}

return &agent.Config{
AgentID: agentID,
InstanceName: hostname,
DiscoveriesConfig: discoveriesConfig,
FactsServiceURL: viper.GetString("facts-service-url"),
PluginsFolder: viper.GetString("plugins-folder"),
PrometheusTargets: prometheusTargets,
}, nil
}
8 changes: 8 additions & 0 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ func NewStartCmd() *cobra.Command {

startCmd.Flags().String("facts-service-url", "amqp://guest:guest@localhost:5672", "Facts service queue url")

startCmd.Flags().
String(
"node-exporter-target",
"",
"Node exporter target address in ip:port notation. If not given the lowest "+
"ipv4 address with the default 9100 port is used",
)

return startCmd
}

Expand Down
10 changes: 9 additions & 1 deletion packaging/config/agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,12 @@

## Facts gathering service URL

# facts-service-url: amqp://guest:guest@localhost:5672
# facts-service-url: amqp://guest:guest@localhost:5672

###############################################################################

## Prometheus exporters targets
## Configure the prometheus targets. If not given, the lowest discovered IP address
## with a default port numbers is used

# node-exporter-target: 192.168.1.10:9100

0 comments on commit 01b8f40

Please sign in to comment.