Skip to content

Instantly share code, notes, and snippets.

View hagen1778's full-sized avatar
💭
I may be slow to respond.

Roman Khavronenko hagen1778

💭
I may be slow to respond.
View GitHub Profile
@hagen1778
hagen1778 / gist:9487f71d9a19e04d521d764b576a0ec2
Last active December 20, 2023 08:57
vmctl trace requests
diff --git a/app/vmctl/main.go b/app/vmctl/main.go
index 95743081f..151e9115b 100644
--- a/app/vmctl/main.go
+++ b/app/vmctl/main.go
@@ -230,7 +230,7 @@ func main() {
if err != nil {
return fmt.Errorf("error initilize auth config for destination: %s", dstAddr)
}
- dstHTTPClient := &http.Client{Transport: &http.Transport{DisableKeepAlives: disableKeepAlive}}
+ dstHTTPClient := &http.Client{Transport: &http.Transport{DisableKeepAlives: disableKeepAlive, ResponseHeaderTimeout: time.Second * 60}}
--- a/app/vmctl/vm_native.go
+++ b/app/vmctl/vm_native.go
@@ -5,8 +5,11 @@ import (
"fmt"
"io"
"log"
+ "net/http/httptrace"
+ "sort"
"strings"
"sync"
@hagen1778
hagen1778 / gist:b073e80374d5b422a9d7687c5274e5ee
Created October 23, 2023 07:33
RW config to send data to multiple destinations
remote_write:
- url: http://<victoriametrics-prod>:8428/api/v1/write
write_relabel_configs:
- source_labels: [env]
regex: "dev"
action: drop
- url: http://<victoriametrics-dev>:8428/api/v1/write
write_relabel_configs:
- source_labels: [env]
regex: "prod"
serviceMonitor:
enabled: true
# disabled, external ruler is used
ruler:
enabled: false
# disabled, external alertmanager is used
alertmanager:
enabled: false
@hagen1778
hagen1778 / slo_rules.yml
Created January 30, 2023 14:12
Code generated by Sloth for vmalert's replay blogpost
---
# Code generated by Sloth (v0.11.0): https://github.com/slok/sloth.
# DO NOT EDIT.
groups:
- name: sloth-slo-sli-recordings-sandbox-vmcluster-requests-availability
rules:
- record: slo:sli_error:ratio_rate5m
expr: |
# vmtag is a docker image tag for VictoriaMetrics components,
# which run inside the prometheus-benchmark - e.g. vmagent, vmalert, vmsingle.
vmtag: "v1.80.0"
# nodeSelector is the list of key-value pairs for selecting instances
# where benchmark pods should be deployed.
nodeSelector: {}
# targetsCount defines the number of nodeexporter instances to scrape.
# This option allows to configure the number of active time series to push
vmselect:
serviceMonitor:
enabled: true
persistentVolume:
enabled: true
size: 15Gi
storageClass: standard-rwo
extraLabels:
cluster: victoria-metrics
extraArgs:
# vmtag is a docker image tag for VictoriaMetrics components,
# which run inside the prometheus-benchmark - e.g. vmagent, vmalert, vmsingle.
vmtag: "v1.80.0"
nodeSelector:
app: rw-benchmark
# targetsCount defines the number of nodeexporter instances to scrape.
# This option allows to configure the number of active time series to push
# to remoteStorages.
@hagen1778
hagen1778 / rules.yml
Created August 8, 2020 21:10
Migrating data from Prometheus to VM. Prometheus rules config
groups:
- name: CPU rules
interval: 10s
rules:
# The count of CPUs per node, useful for getting CPU time as a percent of total.
- record: instance:node_cpus:count
expr: >
count without (cpu, mode) (
node_cpu_seconds_total{mode="idle"}
)
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"github.com/VictoriaMetrics/metrics"
)