martes, 9 de enero de 2024

Configure Grafana and Slack

To configure Grafana to send alerts to Slack, you need to set up a notification channel in Grafana and configure it to use the Slack integration. Here are the steps to configure Grafana to contact Slack:


Create a Slack Workspace:

If you don't already have one, create a Slack workspace where you want to receive Grafana alerts. You can sign up for Slack at https://slack.com/.


Set Up an Incoming Webhook:

To allow Grafana to send messages to Slack, you'll need to create an Incoming Webhook integration in your Slack workspace. Here's how:

Go to your Slack workspace.

Click on your workspace name in the top-left corner and select "Settings & administration" > "Manage apps."

In the "Custom Integrations" section, click on "Incoming Webhooks."

Activate incoming webhooks if they are not already enabled.

Scroll down and click on "Add New Webhook to Workspace."

Select a channel where you want to receive Grafana alerts.

Click "Authorize."

You'll be provided with a Webhook URL. This URL is required for Grafana to send messages to Slack.


Configure a Notification Channel in Grafana:

Log in to your Grafana instance.

Click on the gear icon (⚙️) in the left sidebar to open the "Configuration" menu.

Click on "Notification channels" under the "Alerting" section.

Click on "New Channel" to create a new notification channel.

Configure the channel settings:

Name: Give your channel a descriptive name (e.g., "Slack Alerts").

Type: Select "Slack" from the dropdown menu.

Send reminders: Enable this option if you want to send reminders for unresolved alerts.

Include image: Enable this option to include an image in your alerts (optional).

API URL: Paste the Slack Webhook URL you obtained in step 2 here.

Username: Set the username that will appear in Slack notifications.

Channel: Enter the Slack channel or user where you want to send alerts (e.g., "#general").

Click "Save."

Test the Notification Channel:

After creating the notification channel, you can test it to ensure that alerts are successfully sent to Slack. Click on the "Send Test" button in the notification channel settings to send a test message to Slack. If everything is set up correctly, you should see a message in your Slack channel.


Set Up Alerts in Grafana:

To send alerts to the Slack notification channel, you need to configure alert rules in Grafana. Create or edit a dashboard, add an alert panel, and configure the alert conditions as needed. Then, select the Slack notification channel you created as the "Send to" option for the alert.


Now, when the alert conditions are met, Grafana will send notifications to your specified Slack channel using the configured notification channel.

viernes, 20 de mayo de 2022

Mostrar la rama GIT en Powershell

 Algo muy util en los terminales para los desarrolladores es que se muestre el branch actual de la carpeta en la que uno se encuentra.

Powershell es un terminal para windows muy poderoso el cual es facil de configurar para que podamos añadir el nombre de repositorio en el prompt. Para esto necesitamos ejecutar 2 líneas de comandos en Powershell:

(new-object Net.WebClient).DownloadString("https://raw.githubusercontent.com/psget/psget/master/GetPsGet.ps1") | iex

Add-PoshGitToProfile


La primera línea se encarga de descargar el módulo necesario, lo instala y lo ejecuta.

La segunda línea se encarga de guardar la configuración por defecto cada vez que se inicie el terminal. 

viernes, 19 de noviembre de 2021

Emacs: ejecutar comandos linux en windows (rgrep)

 En Emacs para windows algunos comandos se ejecutan esperando que el sistema sea linux por tanto fallan. 

Para solucionar esto debemos realizar instalaciones adicionales. 

En nuestro caso vamos a probar con el comando rgrep que depende de los comandos grep y find que en windows no encontramos. 

Para esto debemos realizar los siguientes pasos:

1. Primero vamos a http://gnuwin32.sourceforge.net/packages.html donde podemos encontrar los comandos de linux para ser ejecutados en windows. De esta web descargamos Grep y FindUtils y los instalamos. 

Por defecto este software se instalara en: C:\Program Files (x86)\GnuWin32

2. En nuestro archivo de configuración .emacs añadimos las siguientes lineas:

(setq find-program "\"c:\\Program Files (x86)\\GnuWin32\\bin\\find.exe\"")

(setq grep-program "\"c:\\Program Files (x86)\\GnuWin32\\bin\\grep.exe\"")


Con esto le estamos indicando a Emacs que use como programas para buscar los nuevos comandos ingresados.

3. Probamos realizando una búsqueda M-x rgrep 
  • Indicamos los archivos en donde buscaremos [ENTER]  Podemos usar comodines como *.org que buscara en todos los archivos que tengan extensión .org
  • Indicamos el texto a buscar [ENTER]
  • Indicamos la carpeta raíz desde donde buscaremos [ENTER]
Listo, emacs nos devolverá la lista de archivos con la línea que tiene el texto buscado. 

miércoles, 17 de noviembre de 2021

Emacs Doom y swiper

Encontré swiper (https://github.com/abo-abo/swiper) un buscador alternativo a isearch que permite mostrar todos los resultados de búsqueda. 

Para implementarlo en emacs necesitamos configurar los siguiente:

1. En .doom.d/packages.el añadimos el paquete a instalar

(package! swiper)

2, En .doom.d/init.el en la sección de :editor añadimos
swiper

3. En .doom.d/config.el añadimos el shortcut para las búsquedas:
(global-set-key (kbd "C-s") #'swiper-isearch)

4. Ejecutamos .emacs.d/bin/doom.cmd sync y reiniciamos emacs 

Listo, con esta configuración podremos realizar búsquedas de una forma mas efectiva:



python: errno 5 input/output error

 Recientemente tuve el error "errno 5 input/output error" al ejecutar una aplicación en python:

# python3 src/main.py &

El cerrar sesión en el servidor y dejando la ejecución en segundo plano python intenta escribir la salida del comando en la pantalla, pero al cerrar sesión genera el fallo. 

Lo debemos realizar en ese caso es enviar la salida a algún archivo (si buscamos guardar un log) o a /dev/null 

# python3 src/main.py >> /dev/null &

# python3 src/main.py >> /tmp/miapp.log


martes, 23 de marzo de 2021

Instalar emacs doom en windows

 Hoy vamos a cambiar nuestro spacemacs a Doom, la razón principal es velocidad. 

0. Como pre-requisitos necesitamos tener emacs, git cmd y ripreg 

En mi caso emacs se instaló en: C:\Program Files\Emacs\x86_64\bin

En mi caso instale Ripreg en C:\Program Files (x86)\ripgrep-12.1.1-x86_64-pc-windows-msvc

1. Añadimos las variables de entorno

HOME: /Users/[USUARIO]

en PATH añadimos: C:\Program Files\Emacs\x86_64\bin y C:\Program Files (x86)\ripgrep-12.1.1-x86_64-pc-windows-msvc

2. Clonamos Doom

En Git CMD entramos a la carpeta: C:\Users\[USUARIO] y clonamos el proyecto

git clone --depth 1 https://github.com/hlissner/doom-emacs .emacs.d

con esto se debió crear la carpeta: C:\Users\[USUARIO]\.emacs.d

2. Iniciamos la instalación

Seguimos en Git CMD y ejecutamos la instalación:

.emacs.d\bin\doom.cmd install

En este punto debemos de tener un poco de paciencia ...

Listo, ya tendremos nuestra emacs con doom

viernes, 1 de mayo de 2020

spacemacs Package undo-tree is unavailable. Is the package name misspelled?

Si al iniciar la carga de spacemacs nos aparece el mensaje  "Package undo-tree is unavailable. Is the package name misspelled?" quiere decir que no tenemos acceso a una fuenta de paquetes, para habilitar el acceso ejecutamos los siguientes pasos:

1. Editar el archivo .spacemacs cambiando el valor del parámetro dotspacemacs-elpa-https de 1 a nil, si el parámetro  dotspacemacs-elpa-https esta comentado lo descomentamos.

2. Añadir la llave ELPA:
sudo gpg --homedir ~/.emacs.d/elpa/gnupg --receive-keys 066DAFCB81E42C40 

3. Reiniciamos emacs. 

Configure Grafana and Slack

To configure Grafana to send alerts to Slack, you need to set up a notification channel in Grafana and configure it to use the Slack integra...