Skip to content

Instantly share code, notes, and snippets.

View tanmay-bhat's full-sized avatar

Tanmay Bhat tanmay-bhat

View GitHub Profile
@tanmay-bhat
tanmay-bhat / fluentbit-docker-compose.yaml
Last active June 22, 2022 12:42
fluent-bit docker-compose example file which collects and parses apache & nginx logs
version: "3.5"
services:
fluentbit:
image: cr.fluentbit.io/fluent/fluent-bit
ports:
- "24224:24224"
- "24224:24224/udp"
volumes:
- ./:/fluent-bit/etc/
flog:
@tanmay-bhat
tanmay-bhat / parsers.conf
Created May 29, 2022 05:31
Apache & Nginx parser configs for fluent-bit
[PARSER]
Name apache
Format regex
Regex ^(?<host>[^ ]*) [^ ]* (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^\"]*?)(?: +\S*)?)?" (?<code>[^ ]*) (?<size>[^ ]*)(?: "(?<referer>[^\"]*)" "(?<agent>[^\"]*)")?$
Time_Key time
Time_Format %d/%b/%Y:%H:%M:%S %z
[PARSER]
Name nginx
Format regex
@tanmay-bhat
tanmay-bhat / sed-replace.md
Created May 21, 2022 12:37
Use sed to replace value of key-value pair
sed -i '/^old-value /s/=.*$/=new-value/' file-name

Example

cat terraform.tfvars.example project_id = "gcp-123"

@tanmay-bhat
tanmay-bhat / load-kibana-dashboard-metricbeat.md
Created May 18, 2022 06:05
How to load Kibana dashboards from metricbeat pod in kubernetes
  1. Exec into any of the metric beat pod ( part of daemon set ) :
kubectl exec -it <metricbeat-pod-name> bash -n <namespace>
  1. Run the below command :
./metricbeat setup --dashboards -E setup.kibana.host=kibana-kibana:5601
@tanmay-bhat
tanmay-bhat / ssh-config.sh
Last active August 29, 2022 23:26
Shell script to automate configuration of ssh to all servers in KodeKloud Engineer.
#!/bin/bash
set -eu
if ! command -v ssh-keygen &> /dev/null ;then
echo "Cant seem to find 'ssh-keygen' binary, are you sure its installed ?"
exit 1
fi
if ! command -v ssh &> /dev/null ;then
echo "Cant seem to find 'ssh' binary, are you sure its installed ?"
@tanmay-bhat
tanmay-bhat / values.yml
Last active April 12, 2022 18:17
Sample Prometheus values yaml file
rbac:
create: false
podSecurityPolicy:
enabled: false
imagePullSecrets:
# - name: "image-pull-secret"
## Define serviceAccount names for components. Defaults to component's fully qualified name.
@tanmay-bhat
tanmay-bhat / promql.md
Created April 5, 2022 11:58
PromQL expression to exclude multiple labels

Sample scenario :

How to exclude a specific mount-point value of a specific host in a metric node_filesystem_free_bytes ?

node_filesystem_free_bytes{} unless node_filesystem_free_bytes{instance="10.10.0.1",mountpoint="/dir"}

The above query will show available bytes of all hosts & mountpoints except mountpoint /dir on 10.10.0.1


Stackoverflow answer : Link

@tanmay-bhat
tanmay-bhat / config.yml
Last active March 31, 2022 09:36
Configure Readiness Probe alert in Prometheus for Kubernetes
### ALert Configuration
- alert: KubePodReadinessFailure
annotations:
description: Readiness probe for the Pod {{ $labels.pod }} is failing for last 10 minutes
expr: sum by(pod)( kube_pod_info{created_by_kind!="Job"} AND ON (pod, namespace) kube_pod_status_ready{condition="false"} == 1) > 0
for: 10m
labels:
severity: warning
@tanmay-bhat
tanmay-bhat / docker-compose.yaml
Created March 26, 2022 11:09
Simple Docker compose file to start Prometheus server along with node-exporter
version: '3.8'
services:
node-exporter:
image: prom/node-exporter:latest
container_name: node-exporter
restart: unless-stopped
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry.digitalocean.com/tanmaybhat/kube-ops-view latest a645de6a07a3 21 months ago 253MB
registry.digitalocean.com/tanmaybhat/kube-ops-view v1.2.3 a645de6a07a3 21 months ago 253MB
> docker tag registry.digitalocean.com/tanmaybhat/kube-ops-view:latest registry.digitalocean.com/tanmaybhat/kube-ops-view:v1.2.4
> docker images