public class PrometheusScraper extends Object
scrape() is typically the API most consumers will want to use. Given a URL or file, this is
able to give you all the metric data found there, regardless of the format of the data.| Modifier and Type | Class and Description |
|---|---|
protected class |
PrometheusScraper.OpenConnectionDetails |
| Constructor and Description |
|---|
PrometheusScraper(File file,
PrometheusDataFormat dataFormat)
Scrape data from the given file.
|
PrometheusScraper(String host,
int port,
String context) |
PrometheusScraper(URL url) |
PrometheusScraper(URL url,
PrometheusDataFormat dataFormat)
This constructor allows you to explicitly indicate what data format is expected.
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
getBinaryFormatContentType()
This is the content type of the supported Prometheus binary format.
|
protected String |
getTextFormatContentType()
This is the content type of the supported Prometheus text format.
|
protected PrometheusScraper.OpenConnectionDetails |
openConnection(URL endpointUrl)
This provides a hook for subclasses to be able to connect to the Prometheus endpoint
and tell us what the content type is and to give us the actual stream to the data.
|
List<MetricFamily> |
scrape()
This will collect all metric data from the endpoint and
return the entire list of all metric families found there.
|
void |
scrape(PrometheusMetricsWalker walker) |
public PrometheusScraper(String host, int port, String context) throws MalformedURLException
MalformedURLExceptionpublic PrometheusScraper(URL url)
public PrometheusScraper(URL url, PrometheusDataFormat dataFormat)
url - the URL where the Prometheus metric data is founddataFormat - the data format of the metric data found at the URL, or null if
the URL endpoint can provide it for us via content negotiation.#PrometheusScraperUrl(File, PrometheusDataFormat)public PrometheusScraper(File file, PrometheusDataFormat dataFormat)
file - the file to scrapedataFormat - the format of the metric data in the file.public List<MetricFamily> scrape() throws IOException
IOException - if failed to scrape datapublic void scrape(PrometheusMetricsWalker walker) throws IOException
IOExceptionprotected String getBinaryFormatContentType()
protected String getTextFormatContentType()
protected PrometheusScraper.OpenConnectionDetails openConnection(URL endpointUrl) throws IOException
url - the Prometheus endpointIOException - if the connection could not be openedCopyright © 2015–2016 Red Hat, Inc.. All rights reserved.