This is a Agent Check that imports the numeric value returned by Web Scraping as Datadog's custom metrics. By specifying the URL and XPath of the value you want to monitor, you can periodically import it into Datadog.
- Server on which Datadog Agent is installed
Install this Agent Check on this server.
This section describes how to install this Agent Check on Datadog Agent installed on CentOS. Please read accordingly depending on the installation environment.
Install Python Module required for this Agent Check.
$ sudo /opt/datadog-agent/embedded/bin/pip install lxml
Place ./checks.d/web_scraping.py
in this repository in /etc/dd-agent/checks.d/
.
$ sudo cp ./checks.d/web_scraping.py /etc/dd-agent/checks.d/
Create /etc/dd-agent/conf.d/web_scraping.yaml
with reference to ./conf.d/web_scraping.yaml.example
in this repository.
init_config:
min_collection_interval: 60
instances:
- name: wikipedia.en.page.count
url: https://en.wikipedia.org/wiki/Main_Page
xpath: //*[@id="articlecount"]/a[1]/text()
- name: qiita.datadog.entry
url: http://qiita.com/tags/Datadog
xpath: //*[@id="main"]/div/div/div[1]/div[2]/div[1]/div[1]/text()
min_collection_interval
specifies the check interval (in seconds)instances
specify information of the value you want to getname
: Custom metrics name of Datadogurl
: URL of the value you want to getxpath
: XPath of the value you want to getdefault
: Default value when value can not be obtained from html (optional)
If the acquired value contains a value other than a numerical value, only the numerical value is extracted.
You have completed the installation of Agent Check. Please test with the following command.
$ sudo -u dd-agent dd-agent check web_scraping
The numerical value got by Agent Check will be displayed as a log, so please check.
Finally restart Datadog Agent.
$ sudo /etc/init.d/datadog-agent restart
Your custom metrics should now be sent to Datadog.
This software is released under the MIT License, see LICENSE.