This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.management.*; | |
import java.lang.management.ManagementFactory; | |
public class Main { | |
public static void main(String[] args) { | |
try { | |
String programName = (args.length == 0) ? "Java" : args[0]; | |
// Initialize the object | |
SystemStatus systemStatus = new SystemStatus(programName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SystemStatus implements SystemStatusMBean { | |
private Integer numberOfSecondsRunning; | |
private String programName; | |
private Long numberOfUnixSecondsRunning; | |
private Boolean switchStatus; | |
private Thread backgroundThread; | |
public SystemStatus(String programName) { | |
// First we initialize all the metrics | |
this.backgroundThread = new Thread(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import statsd | |
import time | |
if __name__ == '__main__': | |
# Create a new connection for the client | |
connection = statsd.Connection( | |
host='127.0.0.1', | |
port=8125, | |
sample_rate=1, | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SDC = require('statsd-client'); | |
const sdc = new SDC({host: '127.0.0.1'}); | |
setInterval(() => { | |
const timer = new Date(); | |
// Increment counter by one. | |
sdc.increment('node.counter'); | |
// Increment counter by 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/quipo/statsd" | |
"math/rand" | |
"time" | |
) | |
func main() { | |
rand.Seed(time.Now().Unix()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const client = require('prom-client'); | |
const express = require('express'); | |
const server = express(); | |
const register = new client.Registry(); | |
// Probe every 5th second. | |
const intervalCollector = client.collectDefaultMetrics({prefix: 'node_', timeout: 5000, register}); | |
const counter = new client.Counter({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import prometheus_client as prom | |
import random | |
import time | |
req_summary = prom.Summary('python_my_req_example', 'Time spent processing a request') | |
@req_summary.time() | |
def process_request(t): | |
time.sleep(t) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.prometheus.client.Counter; | |
import io.prometheus.client.Gauge; | |
import io.prometheus.client.Histogram; | |
import io.prometheus.client.Summary; | |
import io.prometheus.client.exporter.HTTPServer; | |
import java.io.IOException; | |
import java.util.Random; | |
public class Main { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net/http" | |
"github.com/prometheus/client_golang/prometheus" | |
"github.com/prometheus/client_golang/prometheus/promhttp" | |
"log" | |
"time" | |
"math/rand" |