Skip to content

Commit

Permalink
Use only exporter_exporter for now
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Falck committed Mar 5, 2021
1 parent 2935762 commit c848e38
Showing 1 changed file with 88 additions and 84 deletions.
172 changes: 88 additions & 84 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,84 +37,88 @@ var exporterConfig = ExporterConfig{
port: ExporterExporterPort,
filename: "",
},
{
port: "8081",
filename: "php",
path: "http://%s/metrics",
},
{
port: "9100",
filename: "node",
},
{
port: "9108",
filename: "elasticsearch",
},
{
port: "9114",
filename: "elasticsearch",
},
{
port: "9216",
filename: "mongodb",
},
{
port: "9091",
filename: "minio",
path: "http://%s/minio/prometheus/metrics",
},
{
port: "9101",
filename: "haproxy",
},
{
port: "9104",
filename: "mysql",
},
{
port: "9113",
filename: "nginx",
},
{
port: "9121",
filename: "redis",
},
{
port: "9150",
filename: "memcached",
},
{
port: "9154",
filename: "postfix",
},
{
port: "9182",
filename: "wmi",
},
{
port: "9187",
filename: "postgres",
},
{
port: "9188",
filename: "pgbouncer",
},
{
port: "9189",
filename: "barman",
},
{
port: "9253",
filename: "php-fpm",
},
{
port: "9308",
filename: "kafka",
},
{
port: "9496",
filename: "389ds",
},
/*
disabled those since we only use exporter_exporter on 9999 for now.
TODO move this to a config
{
port: "8081",
filename: "php",
path: "http://%s/metrics",
},
{
port: "9100",
filename: "node",
},
{
port: "9108",
filename: "elasticsearch",
},
{
port: "9114",
filename: "elasticsearch",
},
{
port: "9216",
filename: "mongodb",
},
{
port: "9091",
filename: "minio",
path: "http://%s/minio/prometheus/metrics",
},
{
port: "9101",
filename: "haproxy",
},
{
port: "9104",
filename: "mysql",
},
{
port: "9113",
filename: "nginx",
},
{
port: "9121",
filename: "redis",
},
{
port: "9150",
filename: "memcached",
},
{
port: "9154",
filename: "postfix",
},
{
port: "9182",
filename: "wmi",
},
{
port: "9187",
filename: "postgres",
},
{
port: "9188",
filename: "pgbouncer",
},
{
port: "9189",
filename: "barman",
},
{
port: "9253",
filename: "php-fpm",
},
{
port: "9308",
filename: "kafka",
},
{
port: "9496",
filename: "389ds",
},
*/
}

func main() {
Expand Down Expand Up @@ -322,7 +326,7 @@ func getOldGroups(path string) ([]Group, error) {

oldGroups := []Group{}
err = json.NewDecoder(file).Decode(&oldGroups)
if err == io.EOF { // Ignore empty files
if errors.Is(err, io.EOF) { // Ignore empty files
return nil, nil
}
return oldGroups, err
Expand All @@ -331,11 +335,6 @@ func getOldGroups(path string) ([]Group, error) {
func writeFileSDConfig(config *Config, exporterName string, addresses []Address) error {
path := filepath.Join(config.FileSdPath, exporterName+".json")

previous, err := getOldGroups(path)
if err != nil {
return err
}

groups := []Group{}

for _, v := range addresses {
Expand All @@ -353,6 +352,11 @@ func writeFileSDConfig(config *Config, exporterName string, addresses []Address)
groups = append(groups, group)
}

previous, err := getOldGroups(path)
if err != nil {
return err
}

// Dont remove targets if they happened to be down at the moment
for _, prev := range previous {
exists := false
Expand Down

0 comments on commit c848e38

Please sign in to comment.