Skip to content

Instantly share code, notes, and snippets.

@max-rocket-internet
max-rocket-internet / prom-k8s-request-limits.md
Last active April 15, 2024 08:06
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) /
@FranklinYu
FranklinYu / README.markdown
Last active April 20, 2024 17:08
links for old versions of Docker for Mac (inspired by docker/for-mac#1120)

links for old versions of Docker for Mac

Deprecated

Docker provides download links in release note. They promised that

(we) will also include download links in release notes for future releases.

Note:

@crosbymichael
crosbymichael / machine.go
Created March 23, 2015 23:17
libmachine test API
package main
type Config struct {
Common string
DriverOpts interface{}
}
func main() {
var provider libmachine.Provider
switch driver {
@honza
honza / growl.pl
Created October 1, 2012 00:01
Notification center notifier script for irssi
# == WHAT
# Simple script for notification center notifications in irssi
# Requires terminal-notifier
#
# $ gem install terminal-notifier
#
# == WHO
# Nate Murray 2008
#
# == CONFIG
@supairish
supairish / gist:2951524
Created June 18, 2012 23:58
Nginx - how to limit requests by User Agent
http {
map $http_user_agent $limit_bots {
default '';
~*(google|bing|yandex|msnbot) $binary_remote_addr;
}
limit_req_zone $limit_bots zone=bots:10m rate=1r/m;
server {
@schaary
schaary / ssh_agent_start.fish
Created May 11, 2012 07:33
Auto-launching ssh-agent in fish shell
setenv SSH_ENV $HOME/.ssh/environment
if [ -n "$SSH_AGENT_PID" ]
ps -ef | grep $SSH_AGENT_PID | grep ssh-agent > /dev/null
if [ $status -eq 0 ]
test_identities
end
else
if [ -f $SSH_ENV ]
. $SSH_ENV > /dev/null
@jacobian
jacobian / chunked.py
Created April 18, 2011 20:59
See if your WSGI server will chunk for you.
#
# Run this under your WSGI server, and then try
#
# curl -N -i <server>
#
# If you're chunked, you should see the pause between "hello" and "world".
import time
def application(environ, start_response):
@chrisyour
chrisyour / Folder Preferences
Created December 4, 2010 20:05
Show hidden files and hidden folders (except .git) in your TextMate project drawer
# Want to show hidden files and folders in your TextMate project drawer? Simple, just modify the file and folder patterns in TextMate's preferences.
# Instructions:
# Go to TextMate > Preferences...
# Click Advanced
# Select Folder References
# Replace the following:
# File Pattern
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby