Skip to content

Instantly share code, notes, and snippets.

View binura-g's full-sized avatar

Binura Gunasekara binura-g

  • WSO2 Inc
  • Sydney, Australia
View GitHub Profile
@binura-g
binura-g / winterminal-setup.md
Last active November 8, 2023 00:54
WinTerminal Setup (2023)
@binura-g
binura-g / structured-http-logs-latency-percentiles.csl
Last active July 28, 2022 03:05
Kusto AKS Example - latency percentiles with structured JSON logs
let _Namespace = "namespace_name";
let _ServiceName = "deployment_name";
KubePodInventory
| where Namespace == _Namespace
| where ContainerName has_cs _ServiceName
| distinct ContainerID
| join kind=inner ContainerLog on ContainerID
| where LogEntry has '"type":"http-access"' // filtering out only the http access logs
| extend parsedLog=parse_json(LogEntry)
| extend latencyMs=todouble(parsedLog.responseTimeMs),
@binura-g
binura-g / pod-cpu-usage-percentage.csl
Last active July 28, 2022 02:03
AKS Kusto - Pod CPU Usage percentage
let _Namespace = "namespace_name";
let _ServiceName = "deployment_name";
let _ContainerName = "container_name"; // required only if the Pod has multiple containers (eg. Sidecars)
let _BinSize = 1hr; // 5min, 0.5d, 2d, ...
let _ResourceLimitCounterName = 'cpuLimitNanoCores';
let _ResourceUsageCounterName = 'cpuUsageNanoCores';
KubePodInventory
| where Namespace == _Namespace
| where ServiceName == _ServiceName
| where ContainerName has _ContainerName
@binura-g
binura-g / pod-cpu-usage.csl
Created July 26, 2022 02:00
Kusto-AKS Pod CPU Usage Graph
let _Namespace = "Your namespace";
let _ServiceName = "Your Deployment name";
let _ContainerName = "Specific Container name"; // Only required if you have multiple containers running (eg. Sidecar)
KubePodInventory
| where isnotempty(Computer) // eliminate unscheduled pods
| where PodStatus in ('Running')
| where ServiceName has _ServiceName
| where ContainerName has _ContainerName
| where Namespace == _Namespace
| extend ContainerIdentifier=tostring(split(ContainerName, '/')[1])
@binura-g
binura-g / podlogs_1.csl
Last active July 29, 2022 02:27
Kusto-AKS Pod Logs
let _Namespace = "Your Namespace";
let _ServiceName = "Name of your deployment";
let _ContainerName = "Name of the container"; // Only required if you have multiple containers in the Pod (ie. Sidecars)
KubePodInventory
| project ContainerID, ContainerName, Namespace
| where Namespace == _Namespace
| where ServiceName == _ServiceName
| where ContainerName hasprefix_cs _ContainerName
| distinct ContainerID
| join kind=inner ContainerLog on ContainerID
@binura-g
binura-g / single-line-cert.sh
Last active May 2, 2024 06:52
Convert Certificates ( .pem, / .crt / etc ) into single-line strings for JSON payloads
awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' cert-name.pem
@binura-g
binura-g / ultimate-ut-cheat-sheet.md
Created April 2, 2018 03:41 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


@binura-g
binura-g / main.js
Last active January 15, 2019 02:32
Async and Await example 1
const fs = require("fs");
const FILE = "sample.txt";
// Writes given text to a file asynchronously.
// Returns a Promise.
function write(text) {
return new Promise((resolve, reject) => {
fs.writeFile(FILE, text, err => {
if (err) reject(err);
else resolve();
@binura-g
binura-g / promiseTemplate.js
Created January 29, 2018 16:17
Promises example 2
const myPromise = new Promise((resolve, reject) => {
// do something asynchronous which eventually calls either:
//
// resolve(someValue); // when fulfilled
// or
// reject("failure reason"); // upon failure or rejection
});
@binura-g
binura-g / main.js
Created January 29, 2018 16:10
Promises Example 1
const fs = require("fs");
const FILE = "sample.txt";
// This function returns a promise that the 'text' we pass into
// this function has been asynchrnously written into our FILE.
const writePromise = text => {
return new Promise((resolve, reject) => {
fs.writeFile(FILE, text, err => {
if (err) reject(err);
else resolve();