-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Prometheus config and metric sync
- Loading branch information
Showing
6 changed files
with
686 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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,25 @@ | ||
package internal | ||
|
||
import ( | ||
"github.com/icinga/icinga-go-library/database" | ||
Check failure on line 4 in internal/config.go GitHub Actions / lint
Check failure on line 4 in internal/config.go GitHub Actions / build-test (macos-latest)
Check failure on line 4 in internal/config.go GitHub Actions / build-test (ubuntu-latest)
|
||
"github.com/icinga/icinga-kubernetes/pkg/metrics" | ||
) | ||
|
||
// Config defines Icinga Kubernetes config. | ||
type Config struct { | ||
Database database.Config `yaml:"database"` | ||
Prometheus metrics.PrometheusConfig `yaml:"prometheus"` | ||
} | ||
|
||
// Validate checks constraints in the supplied configuration and returns an error if they are violated. | ||
func (c *Config) Validate() error { | ||
if err := c.Database.Validate(); err != nil { | ||
return err | ||
} | ||
|
||
if err := c.Prometheus.Validate(); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains 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,18 @@ | ||
package metrics | ||
|
||
import "github.com/pkg/errors" | ||
|
||
// PrometheusConfig defines Prometheus configuration. | ||
type PrometheusConfig struct { | ||
Host string `yaml:"host"` | ||
Port int `yaml:"port"` | ||
} | ||
|
||
// Validate checks constraints in the supplied Prometheus configuration and returns an error if they are violated. | ||
func (c *PrometheusConfig) Validate() error { | ||
if c.Host == "" { | ||
return errors.New("Prometheus host missing") | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.