Skip to content

Commit

Permalink
Upgrade prometheus image to v2.19.3
Browse files Browse the repository at this point in the history
- Make e2e prometheus test consistent by querying target metadata API

Signed-off-by: Yuki Tsuboi <ytsuboi@vmware.com>
  • Loading branch information
Yuki Tsuboi authored and srikartati committed Aug 5, 2020
1 parent 5be570b commit 3f84fe3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build/yamls/antrea-prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ spec:
spec:
containers:
- name: prometheus
image: prom/prometheus:v2.2.1
image: prom/prometheus:v2.19.3
args:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus/"
Expand Down
3 changes: 3 additions & 0 deletions docs/prometheus-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Enable Prometheus metrics listener by setting `enablePrometheusMetrics`
parameter to true in the Controller and the Agent configurations.

## Prometheus Configuration

### Prometheus version
Prometheus integration with Antrea is validated as part of CI using Prometheus v2.19.3.

### Prometheus RBAC
Prometheus requires access to Kubernetes API resources for the service discovery
Expand Down
13 changes: 8 additions & 5 deletions test/e2e/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ var prometheusEnabled bool
// Prometheus server JSON output
type prometheusServerOutput struct {
Status string
Data []map[string]string
Data []struct {
Metric string
}
}

func init() {
Expand Down Expand Up @@ -255,8 +257,10 @@ func testMetricsFromPrometheusServer(t *testing.T, data *TestData, prometheusJob
hostIP, nodePort := getPrometheusEndpoint(t, data)

// Build the Prometheus query URL
path := url.PathEscape("match[]={job=\"" + prometheusJob + "\"}")
queryUrl := fmt.Sprintf("http://%s:%d/api/v1/series?%s", hostIP, nodePort, path)
// Target metadata API(/api/v1/targets/metadata) has been available since Prometheus v2.4.0.
// This API is still experimental in Prometheus v2.19.3.
path := url.PathEscape("match_target={job=\"" + prometheusJob + "\"}")
queryUrl := fmt.Sprintf("http://%s:%d/api/v1/targets/metadata?%s", hostIP, nodePort, path)

client := &http.Client{}
resp, err := client.Get(queryUrl)
Expand All @@ -280,8 +284,7 @@ func testMetricsFromPrometheusServer(t *testing.T, data *TestData, prometheusJob
// Create a map of all the metrics which were found on the server
testMap := make(map[string]bool)
for _, metric := range output.Data {
name := strings.TrimSuffix(metric["__name__"], "_bucket")
testMap[name] = true
testMap[metric.Metric] = true
}

// Validate that all the required metrics exist in the server's output
Expand Down

0 comments on commit 3f84fe3

Please sign in to comment.