Comments (4)
My finally solution is "don't use black box exporter". This project has poor documentation and it's much easier, faster and finally better to create own check with report to file /var/metrics/url_responses.prom and export it by node_exporter.
For example:
Run node exporter like this:
node_exporter --collector.textfile.directory=/var/metrics/"
Than write script in your favorite language, that can generate under path /var/metrics/ file *.prom and content like this:
application_response_time{url="appurl.domain.ltd",region="brasil",server_name="my.server.com"} 0.17377614974975586
than I can correlate by server_name, by region etc...
The python primitive way how to generate check like this could be script below, but I removed a few parts so it is maybe broken :-)
#!/usr/bin/env python3
#
# silly multithreeding application check 0.2
#
from multiprocessing import Pool
from urllib.request import Request, urlopen
from urllib.error import URLError, HTTPError
from os import path
import re, sys, time, socket
# import settings
from conf import *
from string import Template
from pprint import pprint
response_time = Template('application_response_time{url="$url",region="$region",server_name="$server"} $time')
def load_file2list(file_path):
''' Read whole file each line is item in array with removed \n char
file_path = str()
'''
try:
if path.isfile(file_path):
with open(file_path, "r") as _F:
return _F.read().splitlines()
else:
print("Required file {} does not exist, so use empty".format(file_path))
return list()
except IOError as err:
print(err)
sys.exit(1)
def check_site(domain):
''' Get https://{{domain}}/ site and try to find SITE: {{domain}} string
in returned page source. Return True if OK, or False.
In case that chack will fail, print simple Error message.
domain = str() # without https://, just domain
'''
# by default application is in error status
_ret = dict(url=domain, region="japan", server=None, time=999999)
try:
# measure response time
t1 = time.time()
req = Request("http://{}/".format(domain))
if len(re.findall('_.O.K._: {}' , str(urlopen(req).read()))) >= 1:
#print('Ok: Domain {} is OK!!!'.format(domain), file=sys.stdout)
_ret['status'] = True
_ret['msg'] = "OK"
else:
#print('Err: Domain {} is BROKEN!!!'.format(domain), file=sys.stderr)
_ret['msg'] = "Broken site" # probably don't contain right domain in source
_ret['time'] = time.time() - t1
_ret['server'] = socket.gethostbyaddr(domain)[0]
except URLError:
_ret['msg'] = "Unrechable"
#print("Err: Domain {} is UNREACHABLE!!!".format(domain), file=sys.stderr)
finally:
return _ret
if __name__ == '__main__':
# load last data
DOMAINS = list(set(load_file2list(PATH_DOMAINS)))
# paralelne jedeme seznam domen
pool = Pool(8)
results = pool.map(check_site, DOMAINS)
with open(PATH_METRICS, "w") as metrics_f:
#metrics_f.seek(0) # rewrite file from begining
for dom in results:
print(response_time.substitute(dom), file=metrics_f)
from blackbox_exporter.
You would create one module per site, each with a different fail_if_not_matches_regexp.
from blackbox_exporter.
Hi you mean that for each site I may create module http_2xx config in blackbox.yml? Please give me an example...
from blackbox_exporter.
iam looking for the same thing, cant we use relabeling.
use the label match_regex="if u read this i am broken" and match_not_regex="if u cant read this i am broken"
from blackbox_exporter.
Related Issues (20)
- When using DNS as the probe protocol, can the hashed value of the resolving result be added to the metric?
- Probe using proxy_url and skip_resolve_phase_with_proxy doesn't work as wanted
- Allow to cache HTTP clients (useful for slow oauth2 probes)
- Provide further breakdown of "processing" phase metric (for oauth2 probes)
- Request for FIPS-Compliant Image HOT 1
- Issue with Proxy Configuration in Blackbox Exporter HOT 1
- Feature request: add possibility to define discoveries consumed by prometheus
- Feature request - cmdline flag to disable/change url for debug pprof endpoints HOT 3
- blackbox http host check can not work normally HOT 1
- Release v0.25.0 - Container Image HOT 1
- Inconsistent support of IPv6 literals HOT 3
- Feature request: probe to prometheus.io is not helpful, should make options or pulldowns HOT 2
- packaged deb version of blackbox_exporter
- Implement DHCP HOT 2
- Recent Probes List - add timestamp or log id as label and column for better identification
- Twistlock CVE's Found 1/24/23 HOT 2
- Cut a new release? HOT 1
- Same blackbox.yml to monitor different proxies
- source_ip_address option enhancement
- Incorrect State in Prometheus HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blackbox_exporter.