All Projects â†’ sohamkamani â†’ Detective

sohamkamani / Detective

Licence: mit
🔎 A distributed application health monitoring library

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Detective

Pixie
Instant Kubernetes-Native Application Observability
Stars: ✭ 589 (+166.52%)
Mutual labels:  monitoring, distributed-systems
Sensu Go
Simple. Scalable. Multi-cloud monitoring.
Stars: ✭ 625 (+182.81%)
Mutual labels:  monitoring, distributed-systems
Akkeeper
An easy way to deploy your Akka services to a distributed environment.
Stars: ✭ 30 (-86.43%)
Mutual labels:  monitoring, distributed-systems
Dbtester
Distributed database benchmark tester
Stars: ✭ 214 (-3.17%)
Mutual labels:  distributed-systems
Prometheus Net.dotnetruntime
Exposes .NET core runtime metrics (GC, JIT, lock contention, thread pool) using the prometheus-net package
Stars: ✭ 214 (-3.17%)
Mutual labels:  monitoring
Webpackmonitor
A tool for monitoring webpack optimization metrics through the development process
Stars: ✭ 2,432 (+1000.45%)
Mutual labels:  monitoring
Ali
Generate HTTP load and plot the results in real-time
Stars: ✭ 3,055 (+1282.35%)
Mutual labels:  monitoring
Javamelody
JavaMelody : monitoring of JavaEE applications
Stars: ✭ 2,486 (+1024.89%)
Mutual labels:  monitoring
Graphite exporter
Server that accepts metrics via the Graphite protocol and exports them as Prometheus metrics
Stars: ✭ 217 (-1.81%)
Mutual labels:  monitoring
Crdt Playground
Stars: ✭ 215 (-2.71%)
Mutual labels:  distributed-systems
Snmpcollector
A full featured Generic SNMP data collector with Web Administration Interface for InfluxDB
Stars: ✭ 216 (-2.26%)
Mutual labels:  monitoring
Wazuh Docker
Wazuh - Docker containers
Stars: ✭ 213 (-3.62%)
Mutual labels:  monitoring
Distributed Systems
MIT课程《Distributed Systems 》学习和翻译
Stars: ✭ 2,546 (+1052.04%)
Mutual labels:  distributed-systems
Deadman
deadman is a curses-based host status checking application using ping
Stars: ✭ 214 (-3.17%)
Mutual labels:  monitoring
Alcali
Featureful Saltstack GUI
Stars: ✭ 218 (-1.36%)
Mutual labels:  monitoring
Awesome Parallel Computing
A curated list of awesome parallel computing resources
Stars: ✭ 212 (-4.07%)
Mutual labels:  distributed-systems
Temboard
PostgreSQL Remote Control
Stars: ✭ 218 (-1.36%)
Mutual labels:  monitoring
Satori
Satori 是一个 LeanCloud 维护的监控系统,inspired by Open-Falcon
Stars: ✭ 216 (-2.26%)
Mutual labels:  monitoring
Docker Traefik Prometheus
A Docker Swarm Stack for monitoring Traefik with Promethues and Grafana
Stars: ✭ 215 (-2.71%)
Mutual labels:  monitoring
Wazuh Kibana App
Wazuh - Kibana plugin
Stars: ✭ 212 (-4.07%)
Mutual labels:  monitoring

Detective 🔎

Build Status GoDoc Coverage Status

Detective is a distributed application health monitoring library. It allows you to monitor arbitrary dependencies in your application, and compose other detective instances to create a distributed monitoring framework.

Usage

A typical service oriented architecture looks like this:

Detective allows you to enable each application to monitor its own dependencies, including dependencies with contain another detective instance. By doing so, you can monitor your infrastructure in a distributed manner, where each service only monitors it's own dependencies.

service oriented architecture with detective

Monitoring a single application

Detective exposes a straightforward API to monitor an arbitrary dependency:

// Initialize a new detective instance
d := detective.New("Another application")

// Create a dependency, and register its detector function
d.Dependency("cache").Detect(func() error {
        err := cache.Ping()
        return err
})

// Create an HTTP endpoint for health checks
http.ListenAndServe(":8081", d)

See the "regular usage" example

The HTTP endpoint can then be used to monitor the health of the application. A GET request to http://localhost:8081/ will return information on the health of the overall application:

{
  "name": "Another application",
  "active": true,
  "status": "Ok",
  "latency": 0,
  "dependencies": [
    {
      "name": "cache",
      "active": true,
      "status": "Ok",
      "latency": 500848512
    }
  ]
}

Composing instances

The endpoint in the previous example can also be used by other detective instances. For example, an application that makes use of "Another application" can monitor it as well:

// Create a new detective instance
d := detective.New("your application")

// Add a dependency, and register a function to detect a fault
d.Dependency("database").Detect(func() error {
        // `db` can be an instance of sql.DB
        err := db.Ping()
        return err
})

// Similarly for the cache
d.Dependency("cache").Detect(func() error {
        err := cache.Ping()
        return err
})

// Add an endpoint, which represents another detective instance ("Another application" in this case)
d.Endpoint("http://localhost:8081/")

// Create a ping endpoint which checks the health of all dependencies
// A Detective instance implements the http.Handler interface
http.ListenAndServe(":8080", d)

See the "composing detective instances" example

Now, when we hit GET http://localhost:8080/, its detective instance will monitor its own dependencies as usual, but also hit the previous dependencies endpoint, and as a result monitor it's dependencies as well :

{
  "name": "your application",
  "active": true,
  "status": "Ok",
  "latency": 0,
  "dependencies": [
    {
      "name": "Another application",
      "active": true,
      "status": "Ok",
      "latency": 0,
      "dependencies": [
        {
          "name": "cache",
          "active": true,
          "status": "Ok",
          "latency": 502210954
        }
      ]
    },
    {
      "name": "db",
      "active": true,
      "status": "Ok",
      "latency": 2500328773
    },
    {
      "name": "db",
      "active": true,
      "status": "Ok",
      "latency": 2500248450
    }
  ]
}

Circular dependencies

It's possible for two applications to depend on each other, either directly, or indirectly. Normally, if you registered two detective instances as dependents of each other, it would result in an infinite loop of HTTP calls to each others ping handler. Detective protects against this situation by adding information about a calling instance to the HTTP header of its request. The callee then inspects this header to find out if it was already part of the calling chain, in which case it ceases to send endpoint HTTP requests, and breaks the circular dependency chain.

Dashboard

The dashboard helps visualize your dependency tree and detect any faulty dependencies, along with their latency:

dashboard picture

To run the dashboard, install the binary with:

go get github.com/sohamkamani/detective/detective-dashboard
go install github.com/sohamkamani/detective/detective-dashboard

Then start the dashboard with:

detective-dashboard -p 8080
## Starts dashboard on http://localhost:8080/

You will then have to enter the URL of any detective endpoint to view its dashboard.

Examples

API documentation

Detailed API documentation can be found on the [GoDocs page]((https://godoc.org/github.com/sohamkamani/detective)

Other implementations

The detective library has also been implemented in Node.js : https://github.com/sohamkamani/detective-node, is iteroperable with this implementation, and can be used as an endpoint.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].