Skip to content

Instantly share code, notes, and snippets.

View diegofcornejo's full-sized avatar
🪄
randomtechguy

Diego Cornejo diegofcornejo

🪄
randomtechguy
View GitHub Profile
@diegofcornejo
diegofcornejo / 1. README.md
Last active September 13, 2024 15:05
Grafana Dashboard for Pino HTTP Logs - Express JS example

Pino HTTP Logs Dashboard
This Grafana dashboard utilizes the Loki data source to visualize and analyze logs generated by the Pino logging library. Logs from HTTP requests are captured using the Pino-HTTP plugin and are sent to a Loki instance via the Pino-Loki plugin, enabling real-time monitoring and historical analysis. The dashboard includes graph and table panels to display key metrics such as request status codes, response times, and error rates, making it easy to track application behavior and identify performance issues.

Flow Overview:

  1. Pino: Captures structured logs in a JSON format.
  2. Pino-HTTP: Specifically designed to handle HTTP request/response logging, capturing details such as request method, URL, and status code.
  3. Pino-Loki: Transmits the
@diegofcornejo
diegofcornejo / README.md
Last active September 15, 2024 05:54
Install Prometheus, Loki and Promtail on Ubuntu 24.04 with Basic Auth

Install Prometheus, Loki and Promtail on Ubuntu 24.04 with Basic Auth

Prometheus Installation Guide

Install Prometheus and Node Exporter

apt -y install prometheus prometheus-node-exporter
@diegofcornejo
diegofcornejo / myip.sh
Created July 25, 2024 04:06
Get IP from bash
alias myip=ipinfo
ipinfo() {
IP=$(curl -s https://ipinfo.io/ip)
curl -s "https://ipinfo.io/widget/demo/$IP" | jq
}
@diegofcornejo
diegofcornejo / macOS.sh
Created June 19, 2024 06:11 — forked from repodevs/macOS.sh
gpg: signing failed: Inappropriate ioctl for device macOS
❱ git config user.signingKey 38AF394C
❱ git config commit.gpgSign true
echo "test" | gpg --clearsign
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
test
gpg: signing failed: Inappropriate ioctl for device
gpg: [stdin]: clear-sign failed: Inappropriate ioctl for device
@diegofcornejo
diegofcornejo / 1. Ollama - Open WebUI.md
Last active June 16, 2024 07:11
Run Ollama Server and Open WebUI with Docker Compose.

ollama-open-webui

This project sets up Ollama and Open WebUI using Docker Compose.

Instructions

  1. Start the services with Docker Compose:
    docker-compose up -d

or

@diegofcornejo
diegofcornejo / uptash_redis_dump_backup_to_r2.sh
Last active June 11, 2024 23:14
Backup Redis dump to Cloudflare R2 using AWS CLI
#!/bin/bash
# Constants
HOST_NAME="$(hostname)"
DATE=$(date +%F-%H%M%S) # Format as 'YYYY-MM-DD-HHMMSS'
AWS_PROFILE="<YOUR_AWS_PROFILE>"
R2_ACCOUNT_ID="<YOUR_R2_ACCOUNT_ID>"
R2_BUCKET="<YOUR_BUCKET_NAME>"
R2_ENDPOINT="https://${R2_ACCOUNT_ID}.r2.cloudflarestorage.com"
REDIS_HOST="<YOUR_REDIS_HOST>"
@diegofcornejo
diegofcornejo / cassandra-rust-example.rs
Last active May 25, 2024 00:52
Cassandra - Rust example (scylladb/scylla-rust-driver)
use scylla::{SessionBuilder, IntoTypedRows};
use std::error::Error;
use std::env;
use std::time::Instant;
use dotenv::dotenv;
const QUERY_LIMIT: i32 = 5000;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
@diegofcornejo
diegofcornejo / cassandra-nodejs-example.js
Last active May 25, 2024 00:49
Cassandra - NodeJS example (datastax/nodejs-driver)
const cassandra = require('cassandra-driver');
const CASSANDRA_HOST = process.env.CASSANDRA_HOST || 'localhost';
const CASSANDRA_NODES = [`${CASSANDRA_HOST}:9042`, `${CASSANDRA_HOST}:9043`, `${CASSANDRA_HOST}:9044`]
const CASSANDRA_USER = process.env.CASSANDRA_USER || 'cassandra';
const CASSANDRA_PASSWORD = process.env.CASSANDRA_PASSWORD || 'cassandra';
const CASSANDRA_DATA_CENTER = process.env.CASSANDRA_DATA_CENTER || 'datacenter1';
const KEYSPACE = 'mykeyspace';
const TABLE = 'event';
const QUERY_LIMIT = 50000;
const FETCH_SIZE = 5000;
@diegofcornejo
diegofcornejo / . CASSANDRA_CLUSTER.md
Last active May 25, 2024 23:21
Cassandra Cluster Setup: Configuration to set up a three-node Cassandra cluster using Docker Compose and the Bitnami Cassandra image.

Cassandra Cluster with Docker Compose

This project sets up a multi-node Cassandra cluster using Docker Compose. The configuration includes three Cassandra nodes with a centralized logging setup using Loki.

Prerequisites

  • Docker
  • Docker Compose

Project Structure

@diegofcornejo
diegofcornejo / docker_backup_volumes_to_r2.sh
Created May 13, 2024 15:03
Backup Docker volumes to Cloudflare R2 using AWS CLI
#!/bin/bash
# Constants
S3_BUCKET="<YOUR_BUCKET_NAME>"
HOST_NAME="$(hostname)"
DATE=$(date +%F-%H%M%S) # Format as 'YYYY-MM-DD-HHMMSS'
MAX_BACKUPS=5
AWS_PROFILE="<YOUR_AWS_PROFILE>"
R2_ACCOUNT_ID="<YOUR_R2_ACCOUNT_ID>"