Skip to content

Instantly share code, notes, and snippets.

View vutkin's full-sized avatar

Viktor Utkin vutkin

  • EPAM Systems
  • Earth
View GitHub Profile
@vutkin
vutkin / README.md
Created September 25, 2024 09:01 — forked from reegnz/README.md
Listing all container images being used in kubernetes cluster

Listing all container images being used in kubernetes cluster

Getting all images referenced in pod specs:

kubectl get pods -A -o json  |
  jq -r '[.items[].spec | (.initContainers // empty | .[].image), .containers[].image] | unique | sort | .[]'

Getting all images cached on nodes:

@vutkin
vutkin / monzo-alertmanager-config.yaml
Created September 12, 2024 14:07 — forked from milesbxf/monzo-alertmanager-config.yaml
Monzo's Alertmanager Slack templates
###################################################
##
## Alertmanager YAML configuration for routing.
##
## Will route alerts with a code_owner label to the slack-code-owners receiver
## configured above, but will continue processing them to send to both a
## central Slack channel (slack-monitoring) and PagerDuty receivers
## (pd-warning and pd-critical)
##
@vutkin
vutkin / kubectl-restarts.sh
Created September 11, 2024 12:10 — forked from mclarke47/kubectl-restarts.sh
Sort pods by restart count
kubectl get pods --sort-by='.status.containerStatuses[0].restartCount'
@vutkin
vutkin / rules.yaml
Created September 7, 2024 19:38 — forked from dmitri-lerko/rules.yaml
Dynamic prometheus alert rules based on team label
# List of kube_*_labels metrics - not all of these are useful for alerting.
# kube_certificatesigningrequest_labels
kube_certificatesigningrequest_labels * on (certificatesigningrequest) group_right(label_team) (
...insert expression here
)
# kube_cronjob_labels
kube_cronjob_labels * on (cronjob, namespace) group_right(label_team) (
...insert expression here
)
@vutkin
vutkin / linux-kill-pts.md
Created July 4, 2024 21:40 — forked from holmberd/linux-kill-pts.md
Kill tty/pts sessions in Linux

Kill user tty/pts sessions in Linux

Commands

  • w: show who is logged on and what they are doing
  • who: show who is logged on
  • tty: show current users pseudo terminal
  • ps -ft pts/1: get process id for the pseudo terminal
  • pkill: signal process based on name and other attributes
git rev-list --all | GIT_PAGER=cat xargs git grep 'search_string'
Prometheus v2.14.0 releases cardinality
stats in the UI!
Useful queries:
1. sum(scrape_series_added) by (job)
2. sum(scrape_samples_scraped) by (job)
3. prometheus_tsdb_symbol_table_size_bytes
4. topk(10, count by (__name__)({__name__=~".+"}))
MM2 internal topics
MM2 uses the following internal topics for replication purposes:
Heartbeat topic: Emitted from the source cluster and replicated to demonstrate connectivity through connectors. This can be used by downstream consumers to verify that the connector is running and the corresponding source cluster is available. Messages in this topic contain information on the source cluster, target cluster, and timestamp when the heartbeat was created.
Checkpoint topic: Emitted in the target cluster by the connector and contains consumer offsets for each consumer group in the source cluster. The connector will periodically query the source cluster for all committed offsets of consumer groups (except for replicated topics) and emit a message to this topic. Information in this message includes the consumer group id, topic, partition, upstream offset, downstream offset, metadata, and timestamp. Consumers use the checkpoint topic via MirrorClient or RemoteClusterUtils class to get the replicated offsets in the
@vutkin
vutkin / gist:926f6d4684f23e8c2075468468e0d179
Created November 25, 2022 11:38
grafana var regexp for pods
get deployment from pods
/.*pod="(\b(?<!-)(?<value>[a-z0-9]+(?:-[a-z0-9]+)*?)(?:-([a-f0-9]{10}))?-([a-z0-9]+)\b(?!-))/g
ref
- https://docs.aws.amazon.com/grafana/latest/userguide/templates-and-variables.html
test:
- https://regex101.com/r/qRiJwA/1
@vutkin
vutkin / heic_to_jpeg.sh
Created November 21, 2022 16:06 — forked from ccnokes/heic_to_jpeg.sh
Bash script that converts .HEIC to .jpg files
#!/bin/bash
set -eu -o pipefail
count=$(find . -depth 1 -name "*.HEIC" | wc -l | sed 's/[[:space:]]*//')
echo "converting $count files .HEIC files to .jpg"
magick mogrify -monitor -format jpg *.HEIC
echo "Remove .HEIC files? [y/n]"