Skip to content

Commit

Permalink
Add ingress gateway metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Raul Sevilla <[email protected]>
  • Loading branch information
rsevilla87 committed Jan 15, 2024
1 parent 292cf22 commit 7caef38
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
7 changes: 3 additions & 4 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ import (
func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
type ConfigDefaulted Config
defaultCfg := ConfigDefaulted{
Warmup: false, // Disable warmup by default
RequestTimeout: time.Second,
Procs: 1,
PrometheusMetrics: prometheusQueries,
Warmup: false, // Disable warmup by default
RequestTimeout: time.Second,
Procs: 1,
}
if err := unmarshal(&defaultCfg); err != nil {
return err
Expand Down
4 changes: 1 addition & 3 deletions pkg/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ type Config struct {
Warmup bool `yaml:"warmup" json:"-"`
// RequestTimeout defines the tool request timeout
RequestTimeout time.Duration `yaml:"requestTimeout" json:"requestTimeout"`
// Prometheus metrics
PrometheusMetrics map[string]string `json:"-"`
}

var prometheusQueries = map[string]string{
var PrometheusQueries = map[string]string{
"avg_cpu_usage_router_pods": "avg(avg_over_time(sum(irate(container_cpu_usage_seconds_total{name!='', namespace='openshift-ingress', pod=~'router-default.+'}[2m])) by (pod)[ELAPSED:]))",
"avg_memory_usage_router_pods_bytes": "avg(avg_over_time(sum(container_memory_working_set_bytes{name!='', namespace='openshift-ingress', pod=~'router-default.+'}) by (pod)[ELAPSED:]))",
"avg_cpu_usage_router_nodes": "avg(avg_over_time(sum(irate(node_cpu_seconds_total{mode!~'idle|steal'}[2m]) and on (instance) label_replace(kube_pod_info{namespace='openshift-ingress'},'instance', '$1', 'node', '(.+)')) by (instance)[ELAPSED:]))",
Expand Down
2 changes: 1 addition & 1 deletion pkg/runner/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func runBenchmark(cfg config.Config, clusterMetadata tools.ClusterMetadata, p *p
timeouts += result.Timeouts
httpErrors += result.HTTPErrors
elapsed := fmt.Sprintf("%ds", int(time.Since(sampleTs).Seconds()))
for field, query := range cfg.PrometheusMetrics {
for field, query := range config.PrometheusQueries {
promQuery := strings.ReplaceAll(query, "ELAPSED", elapsed)
log.Debugf("Running query: %s", promQuery)
value, err := p.Query(promQuery, time.Time{}.UTC())
Expand Down
4 changes: 4 additions & 0 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ func WithServiceMesh(enable bool, igNamespace string) OptsFunctions {
return func(r *Runner) {
r.serviceMesh = enable
r.igNamespace = igNamespace
config.PrometheusQueries["avg_cpu_usage_ingress_gateway_pods"] =
fmt.Sprintf("avg(avg_over_time(sum(irate(container_cpu_usage_seconds_total{name!='', namespace='%s', pod=~'istio-ingressgateway.+'}[2m])) by (pod)[ELAPSED:]))", igNamespace)
config.PrometheusQueries["avg_memory_usage_ingress_gateway_pods_bytes"] =
fmt.Sprintf("avg(avg_over_time(sum(container_memory_working_set_bytes{name!='', namespace='%s', pod=~'istio-ingressgateway.+'}) by (pod)[10m:]))", igNamespace)
}
}

Expand Down

0 comments on commit 7caef38

Please sign in to comment.