Docs | Monitoring | Install | Metrics
Prometheus monitoring for shiny applications, plumber APIs, and other R web services.
I have put this package together in order to 1) grasp a better understanding of Prometheus metrics and 2) have some direct control over the source code of software I deploy for clients. I have written and re-written this three times before discovering openmetrics, an R package that provides the same functionalities. I have taken much inspiration from it.
A simple counter, a value that can only increase, and never decrease.
library(titan)
library(shiny)
ui <- fluidPage(
h1("Hello!")
)
server <- function(input, output){}
# use titanApp
titanApp(
ui, server,
inputs = "inputs",
visits = "visits",
concurrent = "concurrent",
duration = "duration"
)
Using titan in plumber.
#* Increment a counter
#* @get /
function() {
return("Hello titan!")
}
#* Plot a histogram
#* @serializer png
#* @get /plot
function() {
rand <- rnorm(100)
hist(rand)
}
library(plumber)
titan::prTitan("file.R", latency = "latency") %>%
pr_run()
Using titan with ambiorix.
library(titan)
library(ambiorix)
# basic counter
c <- Counter$new(
name = "visits_total",
help = "Total visit to the site",
labels = "path"
)
app <- Ambiorix$new()
app$get("/", function(req, res){
c$inc(path = "/")
res$send("Using {titan} with {ambiorix}!")
})
app$get("/about", function(req, res){
c$inc(path = "/about")
res$send("About {titan} and {ambiorix}!")
})
app$get("/metrics", function(req, res){
res$text(renderMetrics())
})
app$start()
There are other packages out there that will let you serve Prometheus metrics.
- openmetrics provides support for all metrics as well as authentication, and goes a step further in enforcing OpenMetrics standards.
- pRometheus Provides support for Gauge and Counter.
Please note that the titan project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.