Reputation: 69
I'm trying to mimic metrics in Prometheus using Push Gateway. When I'm passing these values in PostMan, I'm able to see the entry of metrics in Push Gateway. But, when I'm trying the same with Rest Assured, it is not working. I'm getting error as RESPONSE :text format parsing error in line 1: invalid metric name.
Anyone has any idea?
public void sendRequestsToPushGateway() {
System.out.println("Send request to Push Gateway");
validatableResponse = given().contentType(ContentType.TEXT)
.body("\"container_cpu_cfs_throttled_seconds_total\"" + "{" + "\"container_name\" = \"test\", "
+ "\"pod_name\"=\"test-stable\"," + "\"exported_namespace\"=\"demo\"" + "} "
+ "100.0\n")
.when()
.put("http://prometheus-pushgateway.eu-mesh-poc-aws.dev.io/metrics/job/cpusaturationtest/instance/3")
.then();
String RESPONSE = validatableResponse.extract().asString();
System.out.println("RESPONSE :" + RESPONSE);
}
Upvotes: 2
Views: 13127
Reputation: 69
I got the solution. I have to remove extra "" from tags like container_name, pod_name & exported_namespace
validatableResponse = given().contentType(ContentType.TEXT)
.body("container_cpu_cfs_throttled_seconds_total"
+ "{container_name = \"test\", pod_name =\"test-stable\",exported_namespace=\"demo\"}"
+ "100.0\n")
.when()
.put("http://prometheus-pushgateway.eu-mesh-poc-aws.dev.io/metrics/job/cpusaturationtest/instance/3")
.then();
Upvotes: 0
Reputation: 6913
Given the code, the page content will be:
"container_cpu_cfs_throttled_seconds_total"{"container_name" = "test", "pod_name"="test-stable","exported_namespace"="demo"} 100.0
There are too many "
and spaces. The content should be:
container_cpu_cfs_throttled_seconds_total{container_name="test",pod_name="test-stable",exported_namespace="demo"} 100.0
You can refer to the Prometheus textfile format.
Upvotes: 4