-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add metrics #21
add metrics #21
Conversation
@@ -29,6 +30,11 @@ type ProviderCredential struct { | |||
Credentials map[string]string `yaml:"credentials"` | |||
} | |||
|
|||
type ProviderApp struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of just the connector, we return this struct now that also contains the time of secret expiry. We can also use it to add more properties later in case that's needed.
@@ -0,0 +1,89 @@ | |||
package azure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved some secret related functions to its own file.
"gopkg.in/yaml.v2" | ||
) | ||
|
||
type azureSecret struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also adding a struct for the secret since returning a bunch of strings is messy and error prone.
"app_registration_name", | ||
} | ||
|
||
AppInfo = prometheus.NewGaugeVec( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the prometheus metric. We create a row for each dex app registration. Its value is the expiry date of the client secret.
|
||
// Gauge for secret expiry time | ||
var ( | ||
infoLabels = []string{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the labels we set on the metrics.
default: | ||
return dexConfig, microerror.Maskf(invalidConfigError, "Owner %s is not known.", provider.GetOwner()) | ||
} | ||
AppInfo.WithLabelValues(s.app.Name, s.app.Namespace, provider.GetOwner(), provider.GetType(), provider.GetName(), appConfig.Name).Set(float64(providerApp.SecretEndDateTime.Unix())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metric is updated for each registered provider in each loop.
@@ -179,3 +180,8 @@ func (r *AppReconciler) NewProvider(p provider.ProviderCredential) (provider.Pro | |||
} | |||
return nil, microerror.Maskf(invalidConfigError, "%s is not a valid provider name.", p.Name) | |||
} | |||
|
|||
func init() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function registers the metric
towards giantswarm/roadmap#1809
this adds a metric containing info about dex app registrations