Probe HTTP URLs and AWS S3 bucket to produce metrics in JSON or for Prometheus.
1.1K
Execute system commands or probe HTTP URLs and AWS S3 buckets to produce metrics in JSON or for Prometheus. Can be used on the command line or as a server.
Inspired by Prometheus Blackbox Exporter.
s3FirstObjectModificationDates3FirstObjectSizes3FirstObjectVersionModificationDates3FirstObjectVersionSizes3LargestObjectSizes3LastObjectModificationDates3LastObjectSizes3LastObjectVersionModificationDates3LastObjectVersionSizes3ObjectsCounts3ObjectsTotalSizes3ObjectVersionsCounts3SmallestObjectSizeVisit http://probeit.herokuapp.com/?target=http://google.com&pretty=true for a sample probe of an HTTP endpoint.
The target query parameter indicates what to probe:
https://google.com, to use the HTTP
probes3://bucket_name, to use the S3 probeThe response will be a JSON object with:
success boolean property indicating whether the probe was successful.metrics array of objects, describing various metrics collected from the
probed target, such as duration of the probe, HTTP status code, number of S3
objects, etc.failures array which may indicate possible causes of the probe's failure.{
"failures": [],
"metrics": [
{
"description": "How long the probe took to complete in seconds",
"name": "duration",
"tags": {},
"type": "seconds",
"value": 0.12
},
...
],
"success": true
}
Run it with Docker
docker run -p 3000:3000 alphahydrae/probeit
Or, run it with npx
npx probeit
Or, install and run it manually
npm install -g probeit
probeit
Then, try it
Visit http://localhost:3000?target=http://google.com&pretty=true
The server's probes provide various metrics about their target, mostly numeric values such as counts, bytesizes, last modification dates, etc.
Each metric is a JSON object with the following format:
{
"description": "What I am",
"name": "myName",
"tags": {
"meta": "data"
},
"type": "seconds",
"value": 1.2
}
The following metric types exist at this time:
true or false.The value of a metric may be null if it cannot be determined (e.g. the
httpCertificateExpiry metric can be null if the
HTTP request is not made over TLS, or the s3LastObjectModificationDate
metric can be null if the S3 bucket contains
no objects).
To get the metrics in Prometheus's text format, use the /metrics path:
http://probeit.herokuapp.com/metrics?target=http://google.com
Metric names are converted from the JSON's camel-case format to underscored
format and the probe_ prefix is prepended (e.g. httpStatusCode
becomes probe_http_status_code). Additionally, the metric's type is added as
a suffix if it's bytes or seconds (e.g. duration becomes
probe_duration_seconds).
Metric tags are added as labels.
All metrics will be provided as gauges by applying the following conversions by type:
true becomes 1 and false becomes 0.null which becomes -1.null
becomes -1.null which becomes NaN.null which becomes -1.null which becomes -1.The following sub-headings document metrics that are provided by all probes.
durationType: seconds
How long the probe took to complete in seconds.
{
"description": "...",
"name": "duration",
"tags": {},
"type": "seconds",
"value": 0.12
}
The command probe is used when the target is an URI that starts with command:,
e.g. command:foo. This will execute the command named foo and return its
metrics.
Named commands must be pre-defined with the commands property of Probe It's
configuration file (config.yml by default, or the file indicated by the -c, --config <FILE> command line option or the $PROBE_CONFIG environment
variable). The property is an object in which keys are command names and values
are the definitions of the commands to run:
commands:
lsRoot:
type: system
command: ls
args: [ -la, / ]
unameAll
type: system
command: uname
args: [ -a ]
The following command types are supported:
If your configuration file is a JavaScript file instead of a JSON or YAML file, you can also define a command to probe as an arbitrary JavaScript function:
exports.commands = {
doStuff: {
type: 'function',
command: async function() {
try {
// Read metrics from a file
const metrics = await fs.Promises.readFile('/metrics.json', 'utf8');
return {
metrics,
failures: [],
success: true
};
} catch (err) {
// Describe possible failure
return {
failures: [
cause: "invalidMetricsFile",
description: "Could not read metrics file"
],
metrics: [],
success: false
};
}
}
}
};
The function may be synchronous or asynchronous, and must return an object with the following properties:
metrics - An array of objects describin the metrics produced by running
the command. Each metrics object must be in the correct format.
failures - An array of objects describing reasons why the probe failed
(it may be empty). Each failure object must have:
cause property which is a string code identifying the failure.description property.expected property indicating the expected value.actual property indicating the actual value which differs from
the expected one.success - true or false to indicate whether the probe succeeded.
System commands are commands that will be spawned in a new process on the machine on which Probe It is running. They can be defined with all configuration file formats (JavaScript, JSON or YAML), for example in JSON:
{
"commands": {
"lsRoot": {
"type": "system",
"command": "ls",
"args": [ "-la", "/" ],
"cwd": "/"
}
}
}
The following options describe a system command:
command - The executable to run.args - An optional array of arguments to pass to the executable.cwd - An optional working directory to run the executable in.The following sub-headings document the metrics provided by a system command probe.
commandExitCodeType: number
The exit code of the executed command. 0 indicates successful execution, while
and non-zero code indicates some kind of failure.
{
"description": "...",
"name": "commandExitCode",
"tags": {},
"type": "number",
"value": 0
}
The HTTP probe is used when the target is an URL that starts with http:// or
https://. By default, it will make a GET request to that URL, following any
redirects, and provide various metrics about the HTTP response.
The following sub-headings document the metrics provided by the HTTP probe.
httpCertificateExpiryType: datetime
Expiration date of the SSL certificate (when the target starts with https://).
{
"description": "...",
"name": "httpCertificateExpiry",
"tags": {},
"type": "datetime",
"value": "2018-05-01T00:00:00Z"
}
httpContentLengthType: bytes
Length of the HTTP response in bytes.
{
"description": "...",
"name": "httpContentLength",
"tags": {},
"type": "bytes",
"value": 2801239
}
httpDurationType: seconds, Repeated
Duration of the HTTP request(s) by phase, summed over all redirects, in seconds. Several instances of this metric will be provided, one for each request phase:
dnsLookup - How long it took to perform the DNS lookup.tcpConnection - How long it took to open the TCP connection after the DNS lookup.tlsHandshake - How long it took to perform the TLS handshake for an HTTPS probe,
after the TCP connection was established. (This metric will be
absent for URLs starting with http://.)firstByte - How long it took to receive the first byte of the response after the
TLS handshake (or TCP connection).contentTransfer - How long it took to transfer the entire response entity once the
first byte was received.{
"description": "...",
"name": "httpDuration",
"tags": {
"phase": "tlsHandshake"
},
"type": "seconds",
"value": 0.02
}
httpRedirectsType: quantity
Number of times HTTP 301 or 302 redirects were followed.
{
"description": "...",
"name": "httpRedirects",
"tags": {},
"type": "quantity",
"value": 2
}
httpSecureType: boolean
Indicates whether SSL/TLS was used for the final redirect.
{
"description": "...",
"name": "httpSecure",
"tags": {},
"type": "boolean",
"value": true
}
httpStatusCodeType: number
HTTP status code of the final response.
{
"description": "...",
"name": "httpStatusCode",
"tags": {},
"type": "number",
"value": 404
}
httpVersionType: number
HTTP version of the final response.
{
"description": "...",
"name": "httpVersion",
"tags": {},
"type": "number",
"value": 1.1
}
The following sub-headings document URL query parameters that can be provided to customize the behavior of the HTTP probe.
allowUnauthorizedType: boolean, Default: false
Whether to consider an HTTP response with an invalid SSL certificate as a success.
?allowUnauthorized=true
followRedirectsType: boolean, Default: true
Whether the probe will follow redirects (e.g. HTTP 301 Moved Permanently or HTTP 302 Found) to provide metrics about the final response, or whether it will simply provide metrics about the first response sent by the server.
?followRedirects=false
headerType: key=value pair, Repeatable
HTTP header to add to the probe's request(s). This parameter can be repeated to set multiple headers.
// The value is "Authorization=Basic YWRtaW46Y2hhbmdlbWUh", URL-encoded
?header=Authorization%3DBasic%20YWRtaW46Y2hhbmdlbWUh
methodType: string (GET, POST, PUT, etc.), Default: GET
The HTTP method to use for the request on the target URL. GET by default.
?method=POST
The following sub-headings document URL query parameters that can be provided to customize how the HTTP probe will determine if it was successful.
By default, it only expects that the final HTTP response will have a code in the 2xx or 3xx range.
expectHttpRedirectsType: boolean or integer
For the probe to be considered successful with this parameter:
true, at least 1 redirect must have been followed.false, no redirect must have been followed.?expectHttpRedirects=true
?expectHttpRedirects=2
Possible failures:
expectHttpRedirectToType: URL
For the probe to be considered successful with this parameter:
// The value is "http://example.com/path", URL-encoded
?expectHttpRedirectTo=http%3A%2F%2Fexample.com%2Fpath
Possible failures:
expectHttpResponseBodyMatchType: regular expression, Repeatable
For the probe to be considered successful with this parameter, the HTTP response body must match the regular expression.
This parameter can be repeated to check the presence of multiple patterns.
// The value is "Catch \d{2}", URL-encoded
?expectHttpResponseBodyMatch=Catch%20%5Cd%7B2%7D
Possible failures:
expectHttpResponseBodyMismatchType: regular expression, Repeatable
For the probe to be considered successful with this parameter, the HTTP response body must not match the regular expression.
This parameter can be repeated to check the absence of multiple patterns.
// The value is "connection lost", URL-encoded
?expectHttpResponseBodyMismatch=connection+lost
Possible failures:
expectHttpSecureType: boolean
For the probe to be considered successful with this parameter:
true, the final HTTP response must have been over TLS (e.g. https://).false, the final HTTP response must not have been over TLS (e.g.
http://).By default, either is considered successful.
Note that this does not affect the probe's behavior of failing if an SSL
certificate is invalid. Use the allowUnauthorized
parameter for that.
?expectHttpSecure=true
Possible failures:
expectHttpStatusCodeType: number or HTTP status code class (e.g. 2xx), Repeatable, Default: [ "2xx", "3xx" ]
For the probe to be considered successful with this parameter, the final HTTP
response's status code must be one of the expected codes, or fall within one of
the expected classes (e.g. 204 falls within the 2xx class). Both individual
codes and code classes may be provided.
?expectHttpStatusCode=204
?expectHttpStatusCode=200&expectHttpStatusCode=3xx
Possible failures:
expectHttpVersionType: number
For the probe to be considered successful with this parameter, the HTTP version of the final response must match the expected version.
?expectHttpVersion=1.1
Possible failures:
The following sub-headings document the possible causes of failure that may be included in the HTTP probe's result.
httpResponseBodyMismatchThe body of the final HTTP response did not match some of the regular
expressions provided with the expectHttpResponseBodyMatch
parameter.
This failure will be repeated for each regular expression that did not match.
{
"cause": "httpResponseBodyMismatch",
"description": "...",
"expected": "[a-z0-9]+"
}
insecureHttpThe final HTTP request was expected to be over TLS due to the expectHttpSecure
parameter being set to true, but it was not.
{
"cause": "insecureHttp",
"description": "..."
}
invalidHttpRedirectCountAn integer was provided as the expected number of redirects with the
expectHttpRedirects parameter, and the actual number
of followed redirects until the final HTTP response did not match that
expectation.
{
"actual": 2,
"cause": "invalidHttpRedirectCount",
"description": "...",
"expected": 1
}
invalidHttpRedirectLocationThe final redirection was expected to be made to the URL specified with the
expectHttpRedirectTo parameter, but a different URL
was provided by the server.
{
"actual": "http://example.com/foo",
"cause": "invalidHttpRedirectLocation",
"description": "...",
"expected": "http://example.com/bar"
}
invalidHttpStatusCodeThe HTTP status code of the final response did not match any of the expected
codes or code classes provided with the expectHttpStatusCode
parameter (or set by default).
{
"actual": 404,
"cause": "invalidHttpStatusCode",
"description": "...",
"expected": [ "200", "3xx" ]
}
invalidHttpVersionThe HTTP version of the final response was not the expected version provided
with the expectHttpVersion parameter.
{
"actual": 2.0,
"cause": "invalidHttpStatusCode",
"description": "...",
"expected": 1.1
}
missingHttpRedirectThe expectHttpRedirects parameter was set to true,
but no redirect was issued by the server.
{
"cause": "missingHttpRedirect",
"description": "..."
}
unexpectedHttpRedirectThe expectHttpRedirects parameter was set to false,
but the server issued one or more redirects.
{
"actual": 3,
"cause": "missingHttpRedirect",
"description": "...",
"expected": 0
}
unexpectedHttpResponseBodyMatchThe body of the final HTTP response matched some of the regular expressions
provided with the expectHttpResponseBodyMismatch
parameter.
This failure will be repeated for each regular expression that matched.
The failure object's actual property will contain the full regular expression
match.
{
"actual": "error: connection lost",
"cause": "unexpectedHttpResponseBodyMatch",
"description": "...",
"expected": "error: .+"
}
unexpectedlySecureHttpThe final HTTP request was expected not to be over TLS due to the
expectHttpSecure parameter being set to false, but it
was.
{
"cause": "unexpectedlySecureHttp",
"description": "..."
}
The S3 probe is used when the target is an URL that starts with s3://. The
format is as follows:
s3://[access_key_id:secret_access_key@]bucket_name[/prefix]
For example:
s3://my_buckets3://A28sdf8A:oa83ufozsr8b@secure_backups/dailyBy default, the probe will list all the objects in the bucket and provide
various metrics about these objects' sizes and last modification dates. It can
also be configured to list object versions with the s3Versions
parameter.
The following sub-headings document the metrics provided by the S3 probe.
s3FirstObjectModificationDateType: datetime
The modification date of the earliest modified object.
{
"description": "...",
"name": "s3FirstObjectModificationDate",
"tags": {},
"type": "datetime",
"value": "2018-05-01T00:00:00Z"
}
s3FirstObjectSizeType: bytes
The size of the earliest modified object in bytes.
{
"description": "...",
"name": "s3FirstObjectSize",
"tags": {},
"type": "bytes",
"value": 1850912
}
s3FirstObjectVersionModificationDateType: datetime
The modification date of the earliest modified object version.
Note: this metric will only be provided if the [s3Versions parameter] is
set to true.
{
"description": "...",
"name": "s3FirstObjectVersionModificationDate",
"tags": {},
"type": "datetime",
"value": "2018-05-01T00:00:00Z"
}
s3FirstObjectVersionSizeType: bytes
The size of the earliest modified object version in bytes.
Note: this metric will only be provided if the [s3Versions parameter] is
set to true.
{
"description": "...",
"name": "s3FirstObjectVersionSize",
"tags": {},
"type": "bytes",
"value": 1850912
}
s3LargestObjectSizeType: bytes
The size of the largest object in bytes.
{
"description": "...",
"name": "s3LargestObjectSize",
"tags": {},
"type": "bytes",
"value": 18392047
}
s3LastObjectModificationDateType: datetime
The modification date of the most recently modified object.
{
"description": "...",
"name": "s3LastObjectModificationDate",
"tags": {},
"type": "datetime",
"value": "2018-05-01T00:00:00Z"
}
s3LastObjectSizeType: bytes
The size of the most recently modified obje
Content type
Image
Digest
Size
35.1 MB
Last updated
over 6 years ago
docker pull alphahydrae/probeit