Customers who sign-up prior to 30/06/2024 get unlimited access to free features, newer features (with some restrictions), but for free for at least 1 year.Sign up now! https://webveta.alightservices.com/
Categories
Welcome

Injecting Metrics into Graphite – Hosted Grafana – Some C# Code samples

There are various solutions for collecting, storing and viewing metrics. This blog post is specifically about the following list of software:

  1. CollectD – For collecting system metrics
  2. Carbon-Relay-ng – Like a server but forwards the metrics into Graphite
  3. Hosted Graphite at Grafana.com – The backend that stores the metrics
  4. Grafana – For viewing metrics
  5. Grafana for alerts

Collectd

Collectd is a very light-weight, low memory, low CPU usage Linux tool that runs as a service and can collect various system related metrics. Collectd is very extensible and has several plugins. Some of the plugins, I like and have used are:

  1. Apache web server – Gathers Apache related stats
  2. ConnTrack – Number of connections in Linux connection tracking table
  3. ContextSwitch – Number of context switches
  4. CPU
  5. DNS
  6. IP-Tables
  7. Load
  8. MySQL
  9. Processes
  10. tcpconns
  11. users
  12. vmem

My favorite output plugins and some I am familiar with are:

  1. CSV
  2. Write Graphite
  3. gRPC

Carbon-relay-ng

This is not necessarily my favorite, because little heavy on system resources 🙁

Now host Carbon-relay-ng on one of the servers, Install Collectd on the servers that need to ingest metrics. Use Collectd’s Write_Graphite for ingesting metrics into Carbon-relay-ng. Configure Carbon-relay-ng to ingest metrics into hosted Graphite on Grafana.com.

For ingesting any code-based metrics use ahd.Graphite.

var client = new CarbonClient("example.com");

var datapoints = new[]
    {
        new Datapoint("data.server1.cpuUsage", 10, DateTime.Now),
        new Datapoint("data.server2.cpuUsage", 15, DateTime.Now),
        new Datapoint("data.server3.cpuUsage", 20, DateTime.Now),
    };

await client.SendAsync(datapoints);

//Sample code from - https://github.com/ahdde/graphite.net

I would say instead of instantiating too many instances, use either singleton or use a very small pool of instances.

I have promised to semi-open-source some code from my upcoming project – Alerts in the anouncements blog. Anyone with some programming knowledge, can implement such a solution by following this blog. This would be implemented slowly because I am planning to get normal 9 – 5 job, instead of joining or participating in the r&aw dawgs human rights violation, game of loans, game of identity distortion (in this case, I am the victim and their offer, if I participate – identity distortion of some American – sorry, I am not a psycho)

Moreover, for at least 6 – 12 months, the project would be offered completely free of charge for some companies / individuals who see a need and can provide feedback.

Roadmap for next few months!

Mr. Kanti Kalyan Arumilli

Arumilli Kanti Kalyan, Founder & CEO
Arumilli Kanti Kalyan, Founder & CEO

B.Tech, M.B.A

Facebook

LinkedIn

Threads

Instagram

Youtube

Founder & CEO, Lead Full-Stack .Net developer

ALight Technology And Services Limited

ALight Technologies USA Inc

Youtube

Facebook

LinkedIn

Phone / SMS / WhatsApp on the following 3 numbers:

+91-789-362-6688, +1-480-347-6849, +44-07718-273-964

+44-33-3303-1284 (Preferred number if calling from U.K, No WhatsApp)

kantikalyan@gmail.com, kantikalyan@outlook.com, admin@alightservices.com, kantikalyan.arumilli@alightservices.com, KArumilli2020@student.hult.edu, KantiKArumilli@outlook.com and 3 more rarely used email addresses – hardly once or twice a year.