Skip to content

Instantly share code, notes, and snippets.

@seankhliao
Created May 26, 2023 15:49
Show Gist options
  • Save seankhliao/497ccd8a60a093c334af066bd83624d0 to your computer and use it in GitHub Desktop.
Save seankhliao/497ccd8a60a093c334af066bd83624d0 to your computer and use it in GitHub Desktop.
c2d debug
receivers:
prometheus:
config:
global:
scrape_interval: 5s
scrape_configs:
- job_name: foo
static_configs:
- targets: ['0.0.0.0:8080']
use_start_time_metric: true
# use_start_time_metric: false
processors:
filter:
metrics:
metric:
- 'name != "foobar"'
transform:
metric_statements:
- context: metric
statements:
- 'set(name, "fizzbuzz")'
cumulativetodelta:
initial_value: auto
exporters:
logging:
verbosity: detailed
connectors:
forward:
service:
pipelines:
metrics/1:
receivers:
- prometheus
processors:
- filter
exporters:
- logging
- forward
metrics/2:
receivers:
- forward
processors:
- transform
- cumulativetodelta
exporters:
- logging
package main
import (
"net/http"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
func main() {
ctr := promauto.NewCounter(prometheus.CounterOpts{
Name: "foobar",
})
go func() {
for range time.NewTicker(time.Second).C {
ctr.Add(1)
}
}()
http.ListenAndServe(":8080", promhttp.Handler())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment