Skip to content

Instantly share code, notes, and snippets.

View mustafayildirim's full-sized avatar
🏠
Working from home

Mustafa YILDIRIM mustafayildirim

🏠
Working from home
View GitHub Profile
@mustafayildirim
mustafayildirim / prom-k8s-request-limits.md
Created November 5, 2024 17:29 — forked from max-rocket-internet/prom-k8s-request-limits.md
How to display Kubernetes request and limit in Grafana / Prometheus properly

CPU: percentage of limit

A lot of people land when trying to find out how to calculate CPU usage metric correctly in prometheus, myself included! So I'll post what I eventually ended up using as I think it's still a little difficult trying to tie together all the snippets of info here and elsewhere.

This is specific to k8s and containers that have CPU limits set.

To show CPU usage as a percentage of the limit given to the container, this is the Prometheus query we used to create nice graphs in Grafana:

sum(rate(container_cpu_usage_seconds_total{name!~".*prometheus.*", image!="", container_name!="POD"}[5m])) by (pod_name, container_name) /
@mustafayildirim
mustafayildirim / get-gcloud-gke-contexts.sh
Created October 17, 2024 23:35 — forked from achetronic/get-gcloud-gke-contexts.sh
Get all the GKE contexts available for you authenticted account
#!/bin/bash
LOCAL_EXIT_CODE=0
# Get a list of projects from Gcloud
PROJECTS=($(gcloud projects list --format="value(projectId)"))
# Create a directory to split clusters kubeconfig files later
mkdir -p "${HOME}/.kube/clusters"

FWIW: I didn't produce the content presented here (the outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@mustafayildirim
mustafayildirim / curl.md
Created January 31, 2018 12:34 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@mustafayildirim
mustafayildirim / readwrite.go
Created January 26, 2018 07:48 — forked from tomcatzh/readwrite.go
Golang readline and writeline
func readLines(path string) ([]string, error) {
file, err := os.Open(path)
if err != nil {
return nil, err
}
defer file.Close()
var lines []string
scanner := bufio.NewScanner(file)
for scanner.Scan() {
Book ID Title Author Links
1-A-1 Red Blood and Black Ink: Journalism in the Old West David Dary Amazon |
1-A-2 Media and the American Mind: From Morse to McLuhan Daniel J. Czitrom Amazon | Goodreads
1-A-3 A Social History of the Media: From Gutenberg to the Internet Peter Burke Amazon | Goodreads
1-A-4 Media Technology and Society: A History From the Telegraph to the Internet Brian Winston Amazon | Goodreads
1-A-5 The Television Will be Revolutionized Amanda D. Lotz Amazon | Goodreads
1-A-
@mustafayildirim
mustafayildirim / gelfsender.sh
Created November 15, 2016 10:44 — forked from gm3dmo/gelfsender.sh
Send a log message to a gelf server using the shell.
# This script can be used to raise a graylog2/gelf message
# gzip it and send it to a graylog server using netcat (nc)
hostname='gelftester'
short_message='test message short version'
full_message='longer test message. dont\n worry be happy'
level=1
facility='gelftester'
# gnu date
date=$(date +'%s.%N')
@mustafayildirim
mustafayildirim / graylog_token.txt
Created November 10, 2016 09:16 — forked from joschi/graylog_token.txt
Graylog access token login
# Create an access token for user "admin" with name "test-1234"
# POST /users/{username}/tokens/{name}
$ curl -i -u admin:admin -H 'Accept: application/json' -X POST 'http://127.0.0.1:12900/users/admin/tokens/test-1234?pretty=true'
HTTP/1.1 200 OK
X-Graylog-Node-ID: cd03ee44-b2a7-4824-be16-bb7456149dbd
Content-Type: application/json
Date: Mon, 08 Aug 2016 12:12:09 GMT
Content-Length: 139
{
DELETE /test
PUT /test
{
"mappings": {
"person": {
"properties": {
"name": { "type": "string" },
"attributes": {
"type": "nested",
@mustafayildirim
mustafayildirim / Linux Static IP
Created November 2, 2016 08:53 — forked from fernandoaleman/Linux Static IP
How To Configure Static IP On CentOS 6
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static