Code Monkey home page Code Monkey logo

uptime_exporter's Introduction

Uptime Exporter

Like UptimeRobot, Uptime Kuma or any other status page monitoring tool, but for Prometheus. So you can display it on your own Grafana.

Installation

Simple!

  1. Download the binary for your OS from the Release page. If you don't see one for your OS/Arch, I'm afraid that you'll need to build it from source.
  2. Create a configuration file, it can be JSON, TOML, or YAML, depending on what you like:
    {
      "endpoints": [
        {
          "name": "GitHub",
          "address": "https://github.com/healthz"
        },
        {
          "name": "Reinaldy",
          "address": "https://code.reinaldyrafli.com",
          "timeout": 60
        }
      ]
    }
    endpoints:
        - name: "GitHub"
          address: https://github.com/healthz
        - name: "Reinaldy"
          address: https://code.reinaldyrafli.com
          timeout: 60
    [[endpoints]]
    name = "Github"
    address = "https://github.com/healthz"
    [[endpoints]]
    name = "Reinaldy"
    address = "htps://code.reinaldyrafli.com"
    timeout = 60
  3. Run the binary!
    uptime_exporter --config-file ./path/to/config.json --web.listen-address :9428

If you want it to listen to a specific interface, you can use flags like so: --web.listen-address 127.0.0.1:9428

Usage

If you're using the default settings, which listens to 0.0.0.0:9428, and you open: http://your-ip:9428/metrics, you will get:

# HELP uptime_is_up Is it up?
# TYPE uptime_is_up gauge
uptime_is_up{endpoint_address="https://code.reinaldyrafli.com",endpoint_name="Reinaldy"} 1
uptime_is_up{endpoint_address="https://github.com/healthz",endpoint_name="GitHub"} 1
# HELP uptime_latency_seconds Measured latency on last scrape
# TYPE uptime_latency_seconds gauge
uptime_latency_seconds{endpoint_address="https://code.reinaldyrafli.com",endpoint_name="Reinaldy"} 0.1414042
uptime_latency_seconds{endpoint_address="https://github.com/healthz",endpoint_name="GitHub"} 0.3379525

uptime_is_up indicates whether the website (as stated by the endpoint_address and endpoint_name fields) is reachable or not by the HTTP request the server just made when Prometheus scrape the page. If the value is 1, then it's up and healthy. If the value is 0, then it's down.

uptime_latency_seconds indicates the time it took to do a HTTP request to that specified endpoint_address field in second.

Configuration file schema

If you want to do config.json.

{
    "endpoints": [
        {
            "name": "string",
            "address": "https://url",
            "method": "GET",
            "timeout": 123,
            "successful_status_code": "2xx",
            "inverse_status": false,
            "tls_configuration": {
                "certificate_authority_path": "/path/to/certificate_authority.pem",
                "client_certificate_path": "/path/to/client_certificate.pem",
                "client_key_path": "/path/to/client_key.pem",
                "insecure_skip_verify": true
            }
        }
    ]
}

If you want to do config.yaml (or .yml if you prefer).

endpoints:
    - name: "string"
      address: "https://url"
      method: "GET"
      timeout: 123
      successful_status_code: 2xx
      inverse_status: false
      tls_configuration:
        certificate_authority_path: "/path/to/certificate_authority.pem",
        client_certificate_path: "/path/to/client_certificate.pem",
        client_key_path: "/path/to/client_key.pem",
        insecure_skip_verify: true

Build from source

Install Go.

go build -o uptime_exporter .

# For windows
go build -o uptime_exporter.exe .

License

MIT License

Copyright (c) 2023 Reinaldy Rafli <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

See LICENSE

uptime_exporter's People

Contributors

aldy505 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.