Skip to content

Commit

Permalink
feat: adding general information (#10)
Browse files Browse the repository at this point in the history
* feat: add cloud project information
* fix: decrease scrape_interval to have consistent prometheus data
* chore: update go modules

---------

Signed-off-by: Rémi Verchère <remi@verchere.fr>
  • Loading branch information
rverchere authored Aug 29, 2023
1 parent 0f8b4ab commit f83f220
Show file tree
Hide file tree
Showing 148 changed files with 3,082 additions and 1,408 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ The following metrics are exported:

| Name | Description | Values |
|------|-------------|--------|
[ ovh_mks_cloud_info | Public cloud projet information (id, name, description, status) | 1 |
| ovh_mks_cluster_info | Cluster information (id, name, region, status, etc) | 1 |
| ovh_mks_cluster_isuptodate | Cluster is up to date (patch/security version) | 0 (no), 1 (yes) |
| ovh_mks_etcd_usage_quota_bytes | ETCD quota max usage | bytes |
| ovh_mks_etcd_usage_usage_bytes | ETCD current usage | bytes |
| ovh_mks_cluster_info | Cluster information (id, name, region, status, etc) | 1 |
| ovh_mks_cluster_nodepool_info | Nodepol information (id, name, nodes number, nodes flavor, etc) ||
| ovh_mks_cluster_instance_info | Instance information (id, name, billing) | 1 |
| ovh_storage_object_count | Swift container object count | count |
Expand Down
6 changes: 3 additions & 3 deletions deployment/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
labels:
app.kubernetes.io/instance: ovh-mks-exporter
app.kubernetes.io/name: ovh-mks-exporter
app.kubernetes.io/version: 1.3.2
app.kubernetes.io/version: 1.3.3
spec:
replicas: 1
selector:
Expand All @@ -17,10 +17,10 @@ spec:
labels:
app.kubernetes.io/instance: ovh-mks-exporter
app.kubernetes.io/name: ovh-mks-exporter
app.kubernetes.io/version: 1.3.2
app.kubernetes.io/version: 1.3.3
spec:
containers:
- image: rverchere/ovh-mks-exporter:1.3.2
- image: rverchere/ovh-mks-exporter:1.3.3
name: ovh-mks-exporter
env:
- name: OVH_ENDPOINT
Expand Down
2 changes: 1 addition & 1 deletion deployment/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
labels:
app.kubernetes.io/instance: ovh-mks-exporter
app.kubernetes.io/name: ovh-mks-exporter
app.kubernetes.io/version: 1.3.2
app.kubernetes.io/version: 1.3.3
spec:
type: ClusterIP
clusterIP: None
Expand Down
6 changes: 3 additions & 3 deletions deployment/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ metadata:
labels:
app.kubernetes.io/instance: ovh-mks-exporter
app.kubernetes.io/name: ovh-mks-exporter
app.kubernetes.io/version: 1.3.2
app.kubernetes.io/version: 1.3.3
release: prom
name: prom-ovh-mks-exporter
spec:
endpoints:
- port: http-metrics
interval: 600s
interval: 180s
scrapeTimeout: 60s
namespaceSelector:
matchNames:
- observability
selector:
matchLabels:
app.kubernetes.io/instance: ovh-mks-exporter
app.kubernetes.io/name: ovh-mks-exporter
app.kubernetes.io/name: ovh-mks-exporter
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
golang.org/x/sys v0.8.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
golang.org/x/sys v0.11.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
)
21 changes: 10 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
Expand All @@ -22,26 +21,26 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8=
github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc=
github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4=
github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w=
github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM=
github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc=
github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg=
github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM=
github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY=
github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU=
github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY=
github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY=
github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI=
github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
Expand Down
26 changes: 22 additions & 4 deletions internal/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ type collector struct {

var (
/* Prometheus related vars */

CloudProjectInfoMetric = "ovh_mks_cloud_info"
CloudProjectInfoHelp = "OVH Public Cloud Information"
CloudProjectInfoDesc = prometheus.NewDesc(CloudProjectInfoMetric, CloudProjectInfoHelp,
[]string{"id", "name", "description", "status"}, nil)

EtcdUsageUsageMetric = "ovh_mks_etcd_usage_usage_bytes"
EtcdUsageUsageHelp = "OVH Managed Kubernetes Service ETCD Usage"
EtcdUsageUsageDesc = prometheus.NewDesc(EtcdUsageUsageMetric, EtcdUsageUsageHelp, []string{"id", "region", "name", "version"}, nil)
Expand Down Expand Up @@ -42,11 +48,11 @@ var (

StorageContainerCountMetric = "ovh_storage_object_count"
StorageContainerCountHelp = "OVH storage containers object count"
StorageContainerCountDesc = prometheus.NewDesc(StorageContainerCountMetric, StorageContainerCountHelp, []string{"id", "region", "name"}, nil)
StorageContainerCountDesc = prometheus.NewDesc(StorageContainerCountMetric, StorageContainerCountHelp, []string{"cloud_project_description", "id", "region", "name"}, nil)

StorageContainerUsageMetric = "ovh_storage_object_bytes"
StorageContainerUsageHelp = "OVH storage containers object bytes"
StorageContainerUsageDesc = prometheus.NewDesc(StorageContainerUsageMetric, StorageContainerUsageHelp, []string{"id", "region", "name"}, nil)
StorageContainerUsageDesc = prometheus.NewDesc(StorageContainerUsageMetric, StorageContainerUsageHelp, []string{"cloud_project_description", "id", "region", "name"}, nil)

InfoMetric = "ovh_mks_exporter_build_info"
InfoHelp = "A metric with a constant '1' value labeled with version, revision, build date, Go version, Go OS, and Go architecture"
Expand All @@ -67,6 +73,7 @@ func Bool2int(b bool) int {
}

func (collector *collector) Describe(ch chan<- *prometheus.Desc) {
ch <- CloudProjectInfoDesc
ch <- EtcdUsageUsageDesc
ch <- EtcdUsageQuotaDesc
ch <- ClusterIsUpToDateDesc
Expand All @@ -80,6 +87,17 @@ func (collector *collector) Describe(ch chan<- *prometheus.Desc) {

func (collector *collector) Collect(ch chan<- prometheus.Metric) {

/* Cloud project global information */
CloudProjectInformation := GetCloudProjectInformation(Client, ServiceName)

ch <- prometheus.MustNewConstMetric(
CloudProjectInfoDesc,
prometheus.GaugeValue,
float64(1),
CloudProjectInformation.ProjectId, CloudProjectInformation.ProjectName, CloudProjectInformation.Description,
CloudProjectInformation.Status,
)

/* Kubernetes Managed Cluster information */
var Clusters []string = GetClusters(Client, ServiceName)

Expand Down Expand Up @@ -153,13 +171,13 @@ func (collector *collector) Collect(ch chan<- prometheus.Metric) {
StorageContainerCountDesc,
prometheus.GaugeValue,
float64(StorageContainer.StoredObjects),
StorageContainer.ID, StorageContainer.Region, StorageContainer.Name,
CloudProjectInformation.Description, StorageContainer.ID, StorageContainer.Region, StorageContainer.Name,
)
ch <- prometheus.MustNewConstMetric(
StorageContainerUsageDesc,
prometheus.GaugeValue,
float64(StorageContainer.StoredBytes),
StorageContainer.ID, StorageContainer.Region, StorageContainer.Name,
CloudProjectInformation.Description, StorageContainer.ID, StorageContainer.Region, StorageContainer.Name,
)

}
Expand Down
31 changes: 31 additions & 0 deletions internal/ovh_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ var (
KubeId string
)

type CloudProjectInformation struct {
// https://transform.tools/json-to-go
ProjectId string `json:"project_id"`
ProjectName string `json:"projectName,omitempty"`
Description string `json:"description,omitempty"`
PlanCode string `json:"planCode"`
Unleash bool `json:"unleash"`
Expiration time.Time `json:"expiration,omitempty"`
CreationDate time.Time `json:"creationDate"`
OrderId int `json:"orderId,omitempty"`
Access string `json:"access"`
Status string `json:"status"`
ManualQuota bool `json:"manualQuota"`
}

type EtcdUsage struct {
Quota int64 `json:"quota"`
Usage int64 `json:"usage"`
Expand Down Expand Up @@ -137,6 +152,22 @@ type KubeNodePoolTemplateSpec struct {
Unschedulable bool `json:"unschedulable"`
}

func GetCloudProjectInformation(client *ovh.Client, ServiceName string) CloudProjectInformation {

log.Info(fmt.Sprintf("Getting cloud project information fo %s", ServiceName))

CloudProjectInformationUrl := fmt.Sprintf("/cloud/project/%s", ServiceName)

var res CloudProjectInformation
err := client.Get(CloudProjectInformationUrl, &res)
if err != nil {
log.Error(err)
}

log.Debug(res)
return res
}

func GetClusterNodePool(client *ovh.Client, ServiceName string, KubeId string) []NodePool {

log.Info(fmt.Sprintf("Getting cluster nodepools for cluster %s", KubeId))
Expand Down
2 changes: 1 addition & 1 deletion internal/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package internal

var Version = "1.3.1"
var Version = "1.3.3"
64 changes: 0 additions & 64 deletions vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go

This file was deleted.

Loading

0 comments on commit f83f220

Please sign in to comment.