Skip to content

Instantly share code, notes, and snippets.

View leegin's full-sized avatar

Darkknight leegin

  • Groww
  • Bangalore
View GitHub Profile
We have to clone the Thanos repo and you'll find a file named "tools.go" inside the cmd/thanos directory.
You need to have "go" installed on your machine before this.
Steps to download go
----
# Download Go for Linux
$ wget https://go.dev/dl/go1.18.3.linux-amd64.tar.gz
$ tar -xvf go1.18.3.linux-amd64.tar.gz
$ mv go /usr/local/
# Add the below line to ~/.bashrc file
SELECT
resource_usage.cluster_name,
resource_usage.cluster_location,
resource_usage.namespace,
resource_usage.labels,
resource_usage.resource_name,
resource_usage.sku_id,
resource_usage.start_time AS usage_start_time,
resource_usage.end_time AS usage_end_time,
resource_usage.usage.amount * gcp_billing_export.rate AS cost
WITH
-- Selective billing data from billing export
billing_data AS (
SELECT
billing_account_id,
service,
sku,
usage_start_time,
usage_end_time,
STRUCT( coalesce(
#/bin/bash
#Script to parse the logs and then convert it to json
read -p ('Enter the name of the log file which you want to parse:') file
while IFS= read -r line
do
ip=`echo $line|cut -d"," -f3`
code=$(curl -s 'http://localhost:3000/'$ip | sed 's/\\\\\//\//g' | sed 's/[{}]//g' | awk -v k="IsoCode" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | sed 's/\"//g' | grep -i isocode | cut -d":" -f2| awk 'NF > 0'| head -n 1)
echo $line,$code >> new.log
done < $file
#/bin/bash
#Script to parse the logs and then convert it to json
read -p ('Enter the name of the log file which you want to parse:') file
jq -Rs '[ split("\n")[] | select(length > 0) | split(",") | {type: .[0], date: .[1], source_ip: .[2], response_time: .[3], target_url: .[4], http_code: .[5]}]' $file > output.json
#/bin/bash
#Script to parse the log to get IP address and URL and then convert it to json
read -p "Enter the name of the log file which you want to parse: " file
less $file | awk '{print $1","$15}' | grep http | cut -d ")" -f1 | sed 's/+//' > data.txt
jq -Rs '[ split("\n")[] | select(length > 0) | split(",") | {IP_address: .[0], URL: .[1]} ]' data.txt > data.json
#!/bin/bash
#Author : Leegin Bernads
read -p "Enter the IAM user name : " user
arn = `aws iam get-user --user-name $user | grep Arn | cut -d ':' -f2,3,4,5,6,7 | tr -d ' ' |sed -e 's/^"//' -e 's/"$//'`
function get_stackname()
{
#With the insatnce id we are getting the instance ip with which the stack name of these instances is gathered in this function.
for i in `cat instanceids.txt`