Query server for exposed Prometheus metrics
curl --request GET \
--url http://localhost:8080/metricsconst url = 'http://localhost:8080/metrics';
const options = {method: 'GET'};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));import requests
url = "http://localhost:8080/metrics"
response = requests.get(url)
print(response.text)package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://localhost:8080/metrics"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}using RestSharp;
var options = new RestClientOptions("http://localhost:8080/metrics");
var client = new RestClient(options);
var request = new RestRequest("");
var response = await client.GetAsync(request);
Console.WriteLine("{0}", response.Content);
HttpResponse<String> response = Unirest.get("http://localhost:8080/metrics")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8080",
CURLOPT_URL => "http://localhost:8080/metrics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}$response = Invoke-WebRequest -Uri 'http://localhost:8080/metrics' -Method GETrequire 'uri'
require 'net/http'
url = URI("http://localhost:8080/metrics")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 2.9153e-05
go_gc_duration_seconds{quantile="0.25"} 6.2832e-05
go_gc_duration_seconds{quantile="0.5"} 9.7187e-05
go_gc_duration_seconds{quantile="0.75"} 0.000112967
go_gc_duration_seconds{quantile="1"} 0.000215819
go_gc_duration_seconds_sum 0.001376862
go_gc_duration_seconds_count 14
API Reference
Query server for exposed Prometheus metrics
See Prometheus documentation for a complete data model.
GET
/
metrics
Query server for exposed Prometheus metrics
curl --request GET \
--url http://localhost:8080/metricsconst url = 'http://localhost:8080/metrics';
const options = {method: 'GET'};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));import requests
url = "http://localhost:8080/metrics"
response = requests.get(url)
print(response.text)package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://localhost:8080/metrics"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}using RestSharp;
var options = new RestClientOptions("http://localhost:8080/metrics");
var client = new RestClient(options);
var request = new RestRequest("");
var response = await client.GetAsync(request);
Console.WriteLine("{0}", response.Content);
HttpResponse<String> response = Unirest.get("http://localhost:8080/metrics")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8080",
CURLOPT_URL => "http://localhost:8080/metrics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}$response = Invoke-WebRequest -Uri 'http://localhost:8080/metrics' -Method GETrequire 'uri'
require 'net/http'
url = URI("http://localhost:8080/metrics")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 2.9153e-05
go_gc_duration_seconds{quantile="0.25"} 6.2832e-05
go_gc_duration_seconds{quantile="0.5"} 9.7187e-05
go_gc_duration_seconds{quantile="0.75"} 0.000112967
go_gc_duration_seconds{quantile="1"} 0.000215819
go_gc_duration_seconds_sum 0.001376862
go_gc_duration_seconds_count 14
Response
200 - text/plain
Successfully returned Prometheus metrics
The response is of type string.
Example:
"# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.\n# TYPE go_gc_duration_seconds summary\ngo_gc_duration_seconds{quantile=\"0\"} 2.9153e-05\ngo_gc_duration_seconds{quantile=\"0.25\"} 6.2832e-05\ngo_gc_duration_seconds{quantile=\"0.5\"} 9.7187e-05\ngo_gc_duration_seconds{quantile=\"0.75\"} 0.000112967\ngo_gc_duration_seconds{quantile=\"1\"} 0.000215819\ngo_gc_duration_seconds_sum 0.001376862\ngo_gc_duration_seconds_count 14\n"
Was this page helpful?