โŒ

Normal view

There are new articles available, click to refresh the page.
Yesterday โ€” 3 June 2025Main stream

Weekly notes 22 2025

3 June 2025 at 14:49

Missed weekly notes for few weeks. Got some interesting days. I reduced the time spent on facebook, twitter, instagram and youtube.
Wanted to work on some long year dreams. I am happy on the progress. Still have to do a lot on these. But giving a start itself a good thing.

  • Working on word lookup based spellchecker for tamil language.
    Implemented bloom filter, bk tree based search/suggestion solution.
    Need to improve with error free tamil words.
    Collecting good words from available tamil datasets.
    May have to work on applying few grammar rules.
    It is a long dream to bring a open source tamil spellcheker.
    Giving some time and focus to work on the dreams.

    see the POC demo here โ€“ https://iyal.kaniyam.ca/
    It is just a POC. there are tons of things to improve.
    Stay tuned or contribute, to see the changes.
  • I want to reduce the content consumption from social media.
    But still want to read the content by beloved writers and bloggers.
    Fortunately, few of them are still writing in their blogs, websites and online magazines.
    Collected the websites of the tamil writers, publishers, literary magazines.
    Hosted a FreshRSS instance here โ€“ https://reader.kaniyam.ca/
    You can also read good tamil content here daily, without any advertisements, promotions, algorithms.

    Let me know if we can add any more tamil sites that are related to literature and technology.
    The only requirement is that the website should provide RSS feeds.
    Sad to know that many webmasters are removing the RSS feeds from their sites.
    Please enable RSS feed in your blogs and websites, so that the content will reach many readers.
  • As I am exploring many websites for good tamil content, found that many websites disappeared from the internet. One of the major reason is missing of domain renewals. we give some email id when registering the domains. But, we switch emails very often. When we get email alerts on the email accounts that we never check, we loss the domains. Working on a dashboard to show the list of domains and their expiry dates. Thanks to python, prometheus and grafana.
    Added around 200 domains to the monitoring list, which I know the persons who manage the domains. I am sending them private messages in whatsapp or telegram or email reminding to renew. Will try to automate the notification. Let me know if you like to add your or any domain to monitoring list.
  • Will release all the code for all of the above this week.
  • Many of my friends are worrying about the future of IT jobs. The recent AI tools are generating good code. Will they lead to human losing the technical jobs? I expect the same. There will be change always. We have to keep on learning new things and be ready to do any kind of job.
    The days of doing same role for many years are gone. In future, we all should be knowing backend, frontend, database, deployment tools. Interesting days are on the way. Be open to learning new things.
  • Nithya released 4th video on GenAI series in Tamil โ€“ Next word prediction using LSTM โ€“ see it here โ€“ https://www.youtube.com/watch?v=-f0QMUOdfOg
  • Tamil Open Source Conference 2025 is happening next month, in chennai. Check the details here โ€“ https://TossConf25.kaniyam.com

    Call for speakers is here โ€“ https://forums.tamillinuxcommunity.org/t/tossconf25-call-for-speakers/2913
  • On Saturdayโ€™s Tamil Grammar meetings, we are working on writing python code for tamil grammar rules using the very old book Tolkappiyam. Join and contribute, if you like to help for tamil language.
  • On Sundays, we meet at Kanchi Linux Users Group online meetings and discuss various open source things. We mentor students and job seekers to do some projects. Dont miss these meetings, to dive into older and modern technologies.
  • All our events are listed in the calendar at https://kaniyam.com/events subscribe to the google calendar there using computer. Thanks to Vanaja for curating all the events and publishing there.
  • Syed Jafer from parottasalna.com is one of the passionate FOSS contributor. He is a good trainer on Python, redis, data structures, git etc. He started a forum to discuss tech things. Post your questions here โ€“ https://forums.parottasalna.com/ Happy to see many forums are being built. Contribute to the open forums, open websites and keep them active and alive.
  • Books completed โ€“ เฎšเฎฎเฎฏเฎ™เฏเฎ•เฎณเฎฟเฎฉเฏ เฎ…เฎฐเฎšเฎฟเฎฏเฎฒเฏ โ€“ เฎคเฏŠ. เฎชเฎฐเฎฎเฎšเฎฟเฎตเฎฉเฏ. , เฎ“เฎฎเฏ เฎทเฎฉเฏเฎฐเฎฟเฎ•เฏเฎ•เฎฟเฎฏเฏ‹ โ€“ เฎชเฎพ. เฎฐเฎพเฎ•เฎตเฎฉเฏ
  • Currently reading โ€“ What the internet is doing to our brains โ€“ The Shallows โ€“ by Nicholas Carr
  • What are you doing interestingly? Write them on your blog as individual blogs or as weekly notes like this.

Weekly notes 22 2025

3 June 2025 at 14:49

Missed weekly notes for few weeks. Got some interesting days. I reduced the time spent on facebook, twitter, instagram and youtube.
Wanted to work on some long year dreams. I am happy on the progress. Still have to do a lot on these. But giving a start itself a good thing.

  • Working on word lookup based spellchecker for tamil language.
    Implemented bloom filter, bk tree based search/suggestion solution.
    Need to improve with error free tamil words.
    Collecting good words from available tamil datasets.
    May have to work on applying few grammar rules.
    It is a long dream to bring a open source tamil spellcheker.
    Giving some time and focus to work on the dreams.

    see the POC demo here โ€“ https://iyal.kaniyam.ca/
    It is just a POC. there are tons of things to improve.
    Stay tuned or contribute, to see the changes.
  • I want to reduce the content consumption from social media.
    But still want to read the content by beloved writers and bloggers.
    Fortunately, few of them are still writing in their blogs, websites and online magazines.
    Collected the websites of the tamil writers, publishers, literary magazines.
    Hosted a FreshRSS instance here โ€“ https://reader.kaniyam.ca/
    You can also read good tamil content here daily, without any advertisements, promotions, algorithms.

    Let me know if we can add any more tamil sites that are related to literature and technology.
    The only requirement is that the website should provide RSS feeds.
    Sad to know that many webmasters are removing the RSS feeds from their sites.
    Please enable RSS feed in your blogs and websites, so that the content will reach many readers.
  • As I am exploring many websites for good tamil content, found that many websites disappeared from the internet. One of the major reason is missing of domain renewals. we give some email id when registering the domains. But, we switch emails very often. When we get email alerts on the email accounts that we never check, we loss the domains. Working on a dashboard to show the list of domains and their expiry dates. Thanks to python, prometheus and grafana.
    Added around 200 domains to the monitoring list, which I know the persons who manage the domains. I am sending them private messages in whatsapp or telegram or email reminding to renew. Will try to automate the notification. Let me know if you like to add your or any domain to monitoring list.
  • Will release all the code for all of the above this week.
  • Many of my friends are worrying about the future of IT jobs. The recent AI tools are generating good code. Will they lead to human losing the technical jobs? I expect the same. There will be change always. We have to keep on learning new things and be ready to do any kind of job.
    The days of doing same role for many years are gone. In future, we all should be knowing backend, frontend, database, deployment tools. Interesting days are on the way. Be open to learning new things.
  • Nithya released 4th video on GenAI series in Tamil โ€“ Next word prediction using LSTM โ€“ see it here โ€“ https://www.youtube.com/watch?v=-f0QMUOdfOg
  • Tamil Open Source Conference 2025 is happening next month, in chennai. Check the details here โ€“ https://TossConf25.kaniyam.com

    Call for speakers is here โ€“ https://forums.tamillinuxcommunity.org/t/tossconf25-call-for-speakers/2913
  • On Saturdayโ€™s Tamil Grammar meetings, we are working on writing python code for tamil grammar rules using the very old book Tolkappiyam. Join and contribute, if you like to help for tamil language.
  • On Sundays, we meet at Kanchi Linux Users Group online meetings and discuss various open source things. We mentor students and job seekers to do some projects. Dont miss these meetings, to dive into older and modern technologies.
  • All our events are listed in the calendar at https://kaniyam.com/events subscribe to the google calendar there using computer. Thanks to Vanaja for curating all the events and publishing there.
  • Syed Jafer from parottasalna.com is one of the passionate FOSS contributor. He is a good trainer on Python, redis, data structures, git etc. He started a forum to discuss tech things. Post your questions here โ€“ https://forums.parottasalna.com/ Happy to see many forums are being built. Contribute to the open forums, open websites and keep them active and alive.
  • Books completed โ€“ เฎšเฎฎเฎฏเฎ™เฏเฎ•เฎณเฎฟเฎฉเฏ เฎ…เฎฐเฎšเฎฟเฎฏเฎฒเฏ โ€“ เฎคเฏŠ. เฎชเฎฐเฎฎเฎšเฎฟเฎตเฎฉเฏ. , เฎ“เฎฎเฏ เฎทเฎฉเฏเฎฐเฎฟเฎ•เฏเฎ•เฎฟเฎฏเฏ‹ โ€“ เฎชเฎพ. เฎฐเฎพเฎ•เฎตเฎฉเฏ
  • Currently reading โ€“ What the internet is doing to our brains โ€“ The Shallows โ€“ by Nicholas Carr
  • What are you doing interestingly? Write them on your blog as individual blogs or as weekly notes like this.
Before yesterdayMain stream

Learning Notes #69 โ€“ Getting Started with k6: Writing Your First Load Test

5 February 2025 at 15:38

Performance testing is a crucial part of ensuring the stability and scalability of web applications. k6 is a modern, open-source load testing tool that allows developers and testers to script and execute performance tests efficiently. In this blog, weโ€™ll explore the basics of k6 and write a simple test script to get started.

What is k6?

k6 is a load testing tool designed for developers. It is written in Go but uses JavaScript for scripting tests. Key features include,

  • High performance with minimal resource consumption
  • JavaScript-based scripting
  • CLI-based execution with detailed reporting
  • Integration with monitoring tools like Grafana and Prometheus

Installation

For installation check : https://grafana.com/docs/k6/latest/set-up/install-k6/

Writing a Basic k6 Test

A k6 test is written in JavaScript. Hereโ€™s a simple script to test an API endpoint,


import http from 'k6/http';
import { check, sleep } from 'k6';

export let options = {
  vus: 10, // Number of virtual users
  duration: '10s', // Test duration
};

export default function () {
  let res = http.get('https://api.restful-api.dev/objects');
  check(res, {
    'is status 200': (r) => r.status === 200,
  });
  sleep(1); // Simulate user wait time
}

Running the Test

Save the script as script.js and execute the test using the following command,

k6 run script.js

Understanding the Output

After running the test, k6 will provide a summary including

1. HTTP requests: Total number of requests made during the test.

    2. Response time metrics:

    • min: The shortest response time recorded.
    • max: The longest response time recorded.
    • avg: The average response time of all requests.
    • p(90), p(95), p(99): Percentile values indicating response time distribution.

    3. Checks: Number of checks passed or failed, such as status code validation.

    4. Virtual users (VUs):

    • vus_max: The maximum number of virtual users active at any time.
    • vus: The current number of active virtual users.

    5. Request Rate (RPS โ€“ Requests Per Second): The number of requests handled per second.

    6. Failures: Number of errors or failed requests due to timeouts or HTTP status codes other than expected.

    Next Steps

    Once youโ€™ve successfully run your first k6 test, you can explore,

    • Load testing different APIs and endpoints
    • Running distributed tests
    • Exporting results to Grafana
    • Integrating k6 with CI/CD pipelines

    k6 is a powerful tool that helps developers and QA engineers ensure their applications perform under load. Stay tuned for more in-depth tutorials on advanced k6 features!

    Event Summary: Grafana & Friends Meetup Chennai โ€“ 25-01-2025

    26 January 2025 at 04:47

    ๐Ÿš€ Attended the Grafana & Friends Meetup Yesterday! ๐Ÿš€

    I usually have a question. As a developer, i have logs, isnโ€™t that enough. With curious mind, i attended Grafana & Friends Chennai meetup (Jan 25th 2025)

    Had an awesome time meeting fellow tech enthusiasts (devops engineers) and learning about cool ways to monitor and understand data better.
    Big shoutout to the Grafana Labs community and Presidio for hosting such a great event!

    Sandwich and Juice was nice ๐Ÿ˜‹

    Talk Summary,

    1โƒฃ Making Data Collection Easier with Grafana Alloy
    Dinesh J. and Krithika R shared how Grafana Alloy, combined with Open Telemetry, makes it super simple to collect and manage data for better monitoring.

    2โƒฃ Running Grafana in Kubernetes
    Lakshmi Narasimhan Parthasarathy (https://lnkd.in/gShxtucZ) showed how to set up Grafana in Kubernetes in 4 different ways (vanilla, helm chart, grafana operator, kube-prom-stack). He is building a SaaS product https://lnkd.in/gSS9XS5m (Heroku on your own servers).

    3โƒฃ Observability for Frontend Apps with Grafana Faro
    Selvaraj Kuppusamy show how Grafana Faro can help frontend developers monitor whatโ€™s happening on websites and apps in real time. This makes it easier to spot and fix issues quickly. Were able to see core web vitals, and traces too. I was surprised about this.

    Techies i had interaction with,

    Prasanth Baskar, who is an open source contributor at Cloud Native Computing Foundation (CNCF) on project https://lnkd.in/gmHjt9Bs. I was also happy to know that he knows **parottasalna** (thatโ€™s me) and read some blogs. Happy To Hear that.

    Selvaraj Kuppusamy, Devops Engineer, he is also conducting Grafana and Friends chapter in Coimbatore on Feb 1. I will attend that aswell.

    Saranraj Chandrasekaran who is also a devops engineer, Had a chat with him on devops and related stuffs.

    To all of them, i shared about KanchiLUG (https://lnkd.in/gasCnxXv) and Parottasalna (https://parottasalna.com/) and My Channel on Tech https://lnkd.in/gKcyE-b5.

    Thanks Achanandhi M for organising this wonderful meetup. You did well. I came to Achanandhi M from medium. He regularly writes blog on cloud related stuffs. https://lnkd.in/ghUS-GTc Checkout his blog.

    Also, He shared some tasks for us,

    1. Create your First Grafana Dashboard.
    Objective: Create a basic Grafana Dashboard to visualize data in various formats such as tables, charts and graphs. Aslo, try to connect to multiple data sources to get diverse data for your dashboard.

    2. Monitor your linux systemโ€™s health with prometheus, Node Exporter and Grafana.
    Objective: Use prometheus, Node Exporter adn Grafana to monitor your linux machines health system by tracking key metrics like CPU, memory and disk usage.


    3. Using Grafana Faro to track User Actions (Like Button Clicks) and Identify the Most Used Features.

    Give a try on these.

    Monitor MySQL DB using Promethus-Grafana/Mysqld exporter

    By: Kannan
    4 November 2023 at 15:57
    • Create a traget machine to install Mysql server
      Here I have created a MySQL target machine using VM (ubuntu 22.04)

    • Lets Install Mysql server
      apt update
      apt install mysql-server
      systemctl start mysql
      systemctl enable mysql
      systemctl status mysql

    • Add prometheus user in prometheus group

    useradd --no-create-home --shell /bin/false prometheus
    
    groupadd --system prometheus
    
    
    useradd -s /sbin/nologin --system -g prometheus prometheus
    
    
    • Downloading latest Mysqld-exporter
    curl -s https://api.github.com/repos/prometheus/mysqld_exporter/releases/latest | grep browser_download_url   | grep linux-amd64 | cut -d '"' -f 4   | wget -qi -
    
    • Extract the downloaded file
    tar xvf mysqld_exporter*.tar.gz
    
    root@mysql-2:~# tar xvf mysqld_exporter*.tar.gz
    mysqld_exporter-0.15.0.linux-amd64/
    mysqld_exporter-0.15.0.linux-amd64/mysqld_exporter
    mysqld_exporter-0.15.0.linux-amd64/NOTICE
    mysqld_exporter-0.15.0.linux-amd64/LICENSE
    
    

    Move the mysqld-exporter to /usr/local/bin

    mv  mysqld_exporter-*.linux-amd64/mysqld_exporter /usr/local/bin/
    
    • giving permission to mysqld-exporter
    chmod +x /usr/local/bin/mysqld_exporter
    
    • verify the mysqld-exporter version

    mysqld_exporter --version

    root@mysql-2:~# mysqld_exporter  --version
    mysqld_exporter, version 0.15.0 (branch: HEAD, revision: 6ca2a42f97f3403c7788ff4f374430aa267a6b6b)
      build user:       root@c4fca471a5b1
      build date:       20230624-04:09:04
      go version:       go1.20.5
      platform:         linux/amd64
      tags:             netgo
    
    
    • Creating MySQL user and DB for mysqld-exporter
    mysql -u root -p
    
    CREATE USER 'mysqld_exporter'@'localhost' IDENTIFIED BY 'StrongPassword';
    
    GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'mysqld_exporter'@'localhost';
    
    FLUSH PRIVILEGES;
    
    EXIT
    
    root@mysql-2:~# mysql -u root -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 8
    Server version: 8.0.35-0ubuntu0.22.04.1 (Ubuntu)
    
    Copyright (c) 2000, 2023, Oracle and/or its affiliates.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> CREATE USER 'mysqld_exporter'@'localhost' IDENTIFIED BY 'password';
    Query OK, 0 rows affected (0.02 sec)
    
    mysql> GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'mysqld_exporter'@'localhost';
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> FLUSH PRIVILEGES;
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> EXIT
    Bye
    
    
    • Configure MySQL DB credentials

    vim /etc/.mysqld_exporter.cnf

    root@mysql-2:~# cat /etc/.mysqld_exporter.cnf
    [client]
    user=mysqld_exporter
    password=******
    
    
    • providing ownership

    chown root:prometheus /etc/.mysqld_exporter.cnf

    • Create systemmd unit file

    vim /etc/systemd/system/mysql_exporter.service

    root@mysql-2:~# cat /etc/systemd/system/mysql_exporter.service
    [Unit]
    Description=Prometheus MySQL Exporter
    After=network.target
    User=prometheus
    Group=prometheus
    
    [Service]
    Type=simple
    Restart=always
    ExecStart=/usr/local/bin/mysqld_exporter \
    --config.my-cnf /etc/.mysqld_exporter.cnf \
    --collect.global_status \
    --collect.info_schema.innodb_metrics \
    --collect.auto_increment.columns \
    --collect.info_schema.processlist \
    --collect.binlog_size \
    --collect.info_schema.tablestats \
    --collect.global_variables \
    --collect.info_schema.query_response_time \
    --collect.info_schema.userstats \
    --collect.info_schema.tables \
    --collect.perf_schema.tablelocks \
    --collect.perf_schema.file_events \
    --collect.perf_schema.eventswaits \
    --collect.perf_schema.indexiowaits \
    --collect.perf_schema.tableiowaits \
    --collect.slave_status \
    --web.listen-address=0.0.0.0:9104
    
    [Install]
    WantedBy=multi-user.target
    
    
    • Reload the daemon and start,enable,status of the service

    systemctl daemon-reload
    systemctl enable mysql_exporter
    systemctl start mysql_exporter
    systemctl status mysql_exporter

    • Already we have created a prometheus server machine and done with the installation of(prometheus,grafana,alertmanager,node-exporter)

    • Adding scrape config file to communicate with db

    vim /etc/prometheus/prometheus.yml

    - job_name: 'server1_db'
        scrape_interval: 5s
        static_configs:
          - targets: ['server_ip:9104']
    
    root@prometheus-2:~# cat etc/prometheus/prometheus.yml
    cat: etc/prometheus/prometheus.yml: No such file or directory
    root@prometheus-2:~# cat /etc/prometheus/prometheus.yml
    
    global:
      scrape_interval: 10s
    
    scrape_configs:
      - job_name: 'prometheus'
        scrape_interval: 5s
        static_configs:
          - targets: ['localhost:9090']
    
      - job_name: 'prometheus_server'
        scrape_interval: 5s
        static_configs:
          - targets: ['192.168.122.138:9100']
    
      - job_name: 'server1_db'
        scrape_interval: 5s
        static_configs:
          - targets: ['192.168.122.137:9104']
    
    
    • Adding Alert rules for msqld-exporter

    vim /etc/prometheus/rules/alert-rules.yml

    alertmanager rules:
    - alert: MysqlDown
        expr: mysql_up == 0
        for: 2m
        labels:
          severity: critical
        annotations:
          summary: MySQL down (instance {{ $labels.instance }})
          description: "MySQL instance is down on {{ $labels.instance }}\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
    
    • Restart and verify the status of all services (prometheus,grafana,node_exporter,alertmanager)

    systemctl restart prometheus
    systemctl status prometheus
    systemctl restart grafana
    systemctl status grafana
    systemctl restart node_exporter
    systemctl status node_exporter
    systemctl restart alertmanager
    systemctl status alertmanager

    • Need to import the JASON file at the Grafana dashboard

    • find the below link to get the JASON file.

    [(https://github.com/prometheus/mysqld_exporter/blob/main/mysqld-mixin/dashboards/mysql-overview.json#L3)]

    • Copy the mysql-overview.jason file from the above link and paste under "import via dashboard JASON model"

    Image description

    • Name the Dashboard and keep time sync "every 5 minutes" and the save the dashboard.

    Image description

    Now we able to Monitor the MySQL DB using Prometheus-Grafana/mysqld-exporter.

    Prometheus & Grafana Installation with Node exporter,Alert Manager,SMTP service configuration for Monitoring

    By: Kannan
    2 November 2023 at 16:05

    Prometheus Installation

    • Do the apt Update
      apt update -y && apt upgrade -y

    • Download prometheus

    wget https://github.com/prometheus/prometheus/releases/download/v2.47.2/prometheus-2.47.2.linux-amd64.tar.gz
    
    

    tar -xvf prometheus-2.47.2.linux-amd64.tar.gz

    • Rename prometheus 2.47.2 to prometheus-files
      mv prometheus-2.47.2.linux-amd64 prometheus-files

    • Add prometheus user
      useradd --no-create-home --shell /bin/false prometheus

    • Create directories and addgroup
      mkdir /etc/prometheus
      mkdir /var/lib/prometheus
      groupadd prometheus

    • Change the ownership of the above created directories
      chown prometheus:prometheus /etc/prometheus
      chown prometheus:prometheus /var/lib/prometheus

    • Copy the prometheus and promtool to /etc/prometheus and provide ownership for the same
      cp -r prometheus-files/consoles /etc/prometheus
      cp -r prometheus-files/console_libraries /etc/prometheus
      chown -R prometheus:prometheus /etc/prometheus/consoles
      chown -R prometheus:prometheus /etc/prometheus/console_libraries

    • Create the prometheus.yml file and set the configuration
      vim /etc/prometheus/prometheus.yml

    root@prometheus-1:/etc/prometheus# cat prometheus.yml 
    global:
      scrape_interval: 10s
    
    scrape_configs:
      - job_name: 'prometheus'
        scrape_interval: 5s
        static_configs:
          - targets: ['localhost:9090']
    
      - job_name: 'prometheus_server'
        scrape_interval: 5s
        static_configs:
          - targets: ['192.168.122.181:9100']
    
    
    • Change the ownership to prometheus user
      chown prometheus:prometheus /etc/prometheus/prometheus.yml

    • Create and setup a prometheus service file
      vim /etc/systemd/system/prometheus.service

    root@prometheus-1:/etc/systemd/system# cat prometheus.service 
    [Unit]
    Description=Prometheus
    Wants=network-online.target
    After=network-online.target
    
    [Service]
    User=prometheus
    Group=prometheus
    Type=simple
    ExecStart=/usr/local/bin/prometheus \
           --config.file /etc/prometheus/prometheus.yml \
           --storage.tsdb.path /var/lib/prometheus/ \
           --storage.tsdb.retention.time=7d \
           --storage.tsdb.retention.size=8GB \
           --web.console.templates=/etc/prometheus/consoles \
           --web.console.libraries=/etc/prometheus/console_libraries
    
    [Install]
    WantedBy=multi-user.target
    
    
    • Reload start and enable the prometheus
    systemctl daemon-reload
    systemctl start prometheus
    systemctl enable prometheus
    systemctl status prometheus
    
    • Access the prometheus on port 9090

    Image description

    Grafana Installation

    • Do apt update and download the Grafana GPG key apt update -y
    wget -q -O - https://packages.grafana.com/gpg.key | gpg --dearmor | sudo tee /usr/share/keyrings/grafana.gpg > /dev/null
    
    root@prometheus-1:/# apt update -y
    Hit:1 http://in.archive.ubuntu.com/ubuntu jammy InRelease
    Hit:2 http://in.archive.ubuntu.com/ubuntu jammy-updates InRelease
    Hit:3 http://in.archive.ubuntu.com/ubuntu jammy-backports InRelease
    Hit:4 http://in.archive.ubuntu.com/ubuntu jammy-security InRelease
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    36 packages can be upgraded. Run 'apt list --upgradable' to see them.
    root@prometheus-1:/# wget -q -O - https://packages.grafana.com/gpg.key | gpg --dearmor | sudo tee /usr/share/keyrings/grafana.gpg > /dev/null
    
    
    • Install APT Grafana Repo
    echo "deb [signed-by=/usr/share/keyrings/grafana.gpg] https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
    
    root@prometheus-1:/# echo "deb [signed-by=/usr/share/keyrings/grafana.gpg] https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
    deb [signed-by=/usr/share/keyrings/grafana.gpg] https://packages.grafana.com/oss/deb stable main
    root@prometheus-1:/# apt update
    Hit:1 http://in.archive.ubuntu.com/ubuntu jammy InRelease
    Hit:2 http://in.archive.ubuntu.com/ubuntu jammy-updates InRelease
    Get:3 https://packages.grafana.com/oss/deb stable InRelease [5,983 B]         
    Hit:4 http://in.archive.ubuntu.com/ubuntu jammy-backports InRelease           
    Hit:5 http://in.archive.ubuntu.com/ubuntu jammy-security InRelease
    Get:6 https://packages.grafana.com/oss/deb stable/main amd64 Packages [163 kB]
    Fetched 169 kB in 2s (70.4 kB/s)
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    36 packages can be upgraded. Run 'apt list --upgradable' to see them.
    
    
    • Install Grafana
      apt install grafana -y

    • Start and enable the Grafana service

    systemctl start grafana-server.service
    systemctl enable grafana-server.service
    systemctl status grafana-server.service
    
    • Find Grafana version
    root@prometheus-1:/# grafana-server -v
    Version 10.2.0 (commit: 895fbafb7a, branch: HEAD)
    
    
    • Access the grafana dashboard on port 3000 login as user:admin & pass:admin and chage the credientials.

    Image description

    Image description

    Node Exporter Installation

    • Download the node exporter
    wget https://github.com/prometheus/node_exporter/releases/download/v1.6.1/node_exporter-1.6.1.linux-amd64.tar.gz
    

    tar -xvf node_exporter-1.6.1.linux-amd64.tar.gz

    • move the node exporter folder to /usr/local/bin
      mv node_exporter-1.6.1.linux-amd64/node_exporter /usr/local/bin/

    • create the group and add the user
      useradd -rs /bin/false node_exporter
      groupadd node_exporter

    • Create the Node exporter service file
      vim /etc/systemd/system/node_exporter.service

    root@prometheus-1:/etc/systemd/system# cat node_exporter.service 
    [Unit]
    Description=Node Exporter
    After=network.target
    [Service]
    User=node_exporter
    Group=node_exporter
    Type=simple
    ExecStart=/usr/local/bin/node_exporter
    [Install]
    WantedBy=multi-user.target
    
    
    • reload, Enable & start the Node exporterservice
    systemctl daemon-reload
    systemctl start node_exporter
    systemctl enable node_exporter
    systemctl status node_exporter
    
    • Access the metrics on port 9100 Image description

    Add Data source

    Home >Dashboard>New>Importdashboard

    Image description

    Alert Manager Installation on Prometheus

    • apt update and download the Alert manager and copy the alert manager file to /usr/local/bin
    wget https://github.com/prometheus/alertmanager/releases/download/v0.26.0/alertmanager-0.26.0.linux-amd64.tar.gz
    

    tar -xvf alertmanager-0.26.0.linux-amd64.tar.gz

    cd alertmanager-0.26.0.linux-amd64/

    cp -r . /usr/local/bin/alertmanager

    • Create the alert manager service file

    vim /etc/systemd/system/alertmanager.service

    root@prometheus-1:/etc/systemd/system# cat node_exporter.service 
    [Unit]
    Description=Node Exporter
    After=network.target
    [Service]
    User=node_exporter
    Group=node_exporter
    Type=simple
    ExecStart=/usr/local/bin/node_exporter
    [Install]
    WantedBy=multi-user.target
    root@prometheus-1:/etc/systemd/system# cat alertmanager.service 
    [Unit]
    Description=Prometheus Alert Manager Service
    After=network.target
    
    [Service]
    Type=simple
    ExecStart=/usr/local/bin/alertmanager/alertmanager \
        --config.file=/usr/local/bin/alertmanager/alertmanager.yml \
        --cluster.advertise-address="192.168.122.181:9093"
    
    [Install]
    WantedBy=multi-user.target
    
    
    • Check the Alert manager with amtool
    /usr/local/bin/alertmanager/amtool check-config /usr/local/bin/alertmanager/alertmanager.yml
    
    root@prometheus-1:~# /usr/local/bin/alertmanager/amtool check-config /usr/local/bin/alertmanager/alertmanager.yml
    Checking '/usr/local/bin/alertmanager/alertmanager.yml'  SUCCESS
    Found:
     - global config
     - route
     - 1 inhibit rules
     - 1 receivers
     - 0 templates
    
    
    • Reload,start & enable the Alert manager service
    systemctl daemon-reload
    systemctl start alertmanager.service
    systemctl enable alertmanager.service
    
    • Access the Alert manager on port 9093

    Image description

    Add alert rules

    • adding alert managerconfiguration on prometheus.yml file which we created on /etc/prometheus/

    add the below parameters before the scarpe_configs

    # Alertmanager configuration
    alerting:
      alertmanagers:
      - static_configs:
        - targets:
           - localhost:9093
    
    # Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
    rule_files:
      - "/etc/prometheus/rules/*.yml"
    

    SMTP Configure for Alert manager

    • To proceed with these setup we need to enable 2-factor authentication on your "Gmail" account and create the "app password" for (prometheus)and copy the key to the below auth password paramater.

    Image description

    • create and add the paramaters on alertmanager.yml
      vim /usr/local/bin/alertmanager/alertmanager.yml

    • Fill the "FROM","TO" email and add the auth key generated from the user gmail account.

    global:
      resolve_timeout: 5m
    
    route:
      group_by: ['alertname']
      group_wait: 10s
      group_interval: 10s
      repeat_interval: 24h
      receiver: 'email'
    receivers:
    - name: 'email'
      email_configs:
      - to: "recepient mail address"@gmail.com
        from: '"usermail address"@gmail.com'
        smarthost: smtp.gmail.com:587
        auth_username: '"usermail address"@gmail.com'
        auth_identity: '"usermail address".com'
        auth_password: '(Key we copied from the appsecurity tab)'
        send_resolved: true
    inhibit_rules:
      - source_match:
          severity: 'critical'
        target_match:
          severity: 'warning'
        equal: ['alertname', 'dev', 'instance']
    
    

    Alert Manager Rule

    • Create the directories to add the rules.

    mkdir /etc/prometheus/rules

    vim /etc/prometheus/rules/alert-rules.yml

    groups:
    - name: alert-rules
      rules:
      - alert: ExporterDown
        expr: up == 0
        for: 2m
        labels:
          severity: critical
        annotations:
          description: 'Metrics exporter service for {{ $labels.job }} running on {{ $labels.instance }} has been down for more than 5 minutes.'
          summary: 'Exporter down (instance {{ $labels.instance }})'
    
      - alert: HostOutOfDiskSpace
        expr: (node_filesystem_avail_bytes * 100) / node_filesystem_size_bytes < 15 and ON (instance, device, mountpoint) node_filesystem_readonly == 0
        for: 2m
        labels:
          severity: warning
        annotations:
          summary: Host out of disk space (instance {{ $labels.instance }})
          description: "Disk is almost full (< 15% left)\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
    
      - alert: HostOutOfMemory
        expr: node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100 < 15
        for: 2m
        labels:
          severity: warning
        annotations:
          summary: Host out of memory (instance {{ $labels.instance }})
          description: "Node memory is filling up (< 15% left)\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
    
      - alert: HostHighCpuLoad
        expr: 100 - (avg by(instance) (rate(node_cpu_seconds_total{mode="idle"}[2m])) * 100) > 85
        for: 2m
        labels:
          severity: warning
        annotations:
          summary: Host high CPU load (instance {{ $labels.instance }})
          description: "CPU load is > 85%\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
    

    Image description

    To check and find the status validation of alertmanager.yml and rules with amtool & promtool

    /usr/local/bin/alertmanager/amtool check-config /usr/local/bin/alertmanager/alertmanager.yml
    
    promtool check rules /etc/prometheus/rules/alert-rules.yml
    
    
    root@prometheus-1:~# /usr/local/bin/alertmanager/amtool check-config /usr/local/bin/alertmanager/alertmanager.yml
    Checking '/usr/local/bin/alertmanager/alertmanager.yml'  SUCCESS
    Found:
     - global config
     - route
     - 1 inhibit rules
     - 1 receivers
     - 0 templates
    
    root@prometheus-1:~# promtool check rules /etc/prometheus/rules/alert-rules.yml
    Checking /etc/prometheus/rules/alert-rules.yml
      SUCCESS: 4 rules found
    
    

    Restart all the services like prometheus,node exporter,Alert manager,grafana

    • We have verified the disk space and added file.img to check the alertmanager and rules.
    root@prometheus-1:~# df -h
    Filesystem                         Size  Used Avail Use% Mounted on
    tmpfs                              392M  1.3M  390M   1% /run
    /dev/mapper/ubuntu--vg-ubuntu--lv   12G  7.3G  3.4G  69% /
    tmpfs                              2.0G     0  2.0G   0% /dev/shm
    tmpfs                              5.0M     0  5.0M   0% /run/lock
    /dev/vda2                          2.0G  251M  1.6G  14% /boot
    tmpfs                              392M  4.0K  392M   1% /run/user/1000
    root@prometheus-1:~# fallocate -l 2G file.img
    root@prometheus-1:~# df -h
    Filesystem                         Size  Used Avail Use% Mounted on
    tmpfs                              392M  1.3M  390M   1% /run
    /dev/mapper/ubuntu--vg-ubuntu--lv   12G  9.3G  1.4G  88% /
    tmpfs                              2.0G     0  2.0G   0% /dev/shm
    tmpfs                              5.0M     0  5.0M   0% /run/lock
    /dev/vda2                          2.0G  251M  1.6G  14% /boot
    tmpfs                              392M  4.0K  392M   1% /run/user/1000
    root@prometheus-1:~# ls
    
    

    -Grafana Dashboard status.
    Image description

    โŒ
    โŒ