Skip to content

Instantly share code, notes, and snippets.

@anandsunderraman
anandsunderraman / logback.xml
Last active February 2, 2024 02:21
logback configuration for structured logging
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender class="ch.qos.logback.core.ConsoleAppender" name="stdout">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %5p [appName:%thread:%X{X-B3-TraceId}:%X{X-B3-SpanId}] %logger{40} - %msg%n
</pattern>
</encoder>
</appender>
<appender class="ch.qos.logback.core.ConsoleAppender" name="jsonstdout">
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
@anandsunderraman
anandsunderraman / kibanaWatcherWithSlack.json
Created March 17, 2020 17:21
Kibana watcher with slack action
{
"trigger": {
"schedule": {
"interval": "1m" //how frequently you want the alert to run
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
@anandsunderraman
anandsunderraman / bruteForce.js
Last active May 3, 2020 18:11
Copying data from mongodb to s3 in a lambda
const MongoClient = require('mongodb').MongoClient;
let s3Client = require('aws-sdk/clients/s3');
//brute force method loading all the data into an array
exports.copyData = async (event, context) => {
//this is required for node js mongodb connection pooling
context.callbackWaitsForEmptyEventLoop = false;
@anandsunderraman
anandsunderraman / logger.js
Created June 11, 2020 05:27
node structured logging configuration
'use strict';
const winston = require('winston');
const MESSAGE = Symbol.for('message');
const jsonFormatter = (logEntry) => {
const base = { timestamp: new Date() };
const json = Object.assign(base, logEntry)
logEntry[MESSAGE] = JSON.stringify(json);
return logEntry;
@anandsunderraman
anandsunderraman / docker-compose.yml
Last active September 21, 2020 03:37
ELK docker compose
version: '3'
services:
elastic:
image: docker.elastic.co/elasticsearch/elasticsearch:6.6.0
ports:
- "9200:9200"
- "9300:9300"
environment:
- discovery.type=single-node
This file has been truncated, but you can view the full file.
{
"format": "graph-model",
"generatedBy": "2.3.0",
"convertedBy": "TensorFlow.js Converter v2.4.0",
"userDefinedMetadata": {
"signature": {
"inputs": {
"input_tensor:0": {
"name": "input_tensor:0",
"dtype": "DT_UINT8",
@anandsunderraman
anandsunderraman / terminal-git-branch-name.md
Created January 8, 2021 14:56 — forked from joseluisq/terminal-git-branch-name.md
Add Git Branch Name to Terminal Prompt (Linux/Mac)

Add Git Branch Name to Terminal Prompt (Linux/Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {
@anandsunderraman
anandsunderraman / grpcurlLibrary.go
Created February 4, 2021 14:32
Using grpcurl as a library
package main
import (
"bytes"
"fmt"
"github.com/fullstorydev/grpcurl"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
@anandsunderraman
anandsunderraman / cheatsheet.md
Created May 10, 2022 15:46 — forked from domanchi/cheatsheet.md
[splunk cheatsheet] Splunk snippets, because their syntax is so confusing. #splunk

Splunk Queries

I really don't like Splunk documentation. Why is it so hard to find out how to do a certain action? So this is a cheatsheet that I constructed to help me quickly gain knowledge that I need.

Analysis

Events over time

index="my_log"
@anandsunderraman
anandsunderraman / mapofmapofstringtostring.json
Created August 24, 2022 13:32
JSON Schema for a map of map of string and string
{
"$defs":
{
"MapStringToString":
{
"type": "object",
"additionalProperties":
{
"type": "string"
}