Graphite threshold alerting with Sensu

Instrumenting your code to report application level metrics is definitely one of the most powerful monitoring tasks you can accomplish.  It is damn satisfying to get working the first time as well.  Having the ability to look at your application and how it is performing at a granular level can help identify potential issues or bottlenecks but can also give you a greater understanding of how people are interacting with the application at a broad scale.  Everybody loves having these types of metrics to talk about their apps and products so this style of monitoring is a great win for the whole team.

I don’t want to dive in to the specifics of WHAT you should monitor here, that will be unique to every environment.  Instead of covering the what and how of instrumenting the code to report specific metrics, I will be running through an example of what the process might look like for instrumenting a check and alarm for monitoring and alerting purposes at an operations level.  I am not a developer, so I don’t spend a lot of time thinking about what types of things are important to collect metrics on.  Usually my job instead is to figure out how to monitor and alert effectively, based on the metrics that developers come up with.

Sensu has a great plugin to check Graphite thresholds in their plugin repo.  If you haven’t looked already, take a minute to glance over the options a little bit and see how the plugin works.  It is a pretty simple plugin but has been able to do everything I need it to.

One common monitoring task is to check how long requests are taking.  So in this example, we are querying the Graphite server and reporting a critical  status (status 1) if the request averages more than 7 seconds for a response time.

Here is the command you would run manually to check this threshold.  Make sure to download the script if you haven’t already, you can just copy the code directly or clone the repo if you are doing this manually.  If you are using Sensu you can use the sensu_plugin LWRP to grab the script (more on that below).

./check-data -s <servername:port> -t <graphite query> -c 7000 -u user -p password
./check-data -s graphite.example.com -t alias(stats.timer.server.response_time.mean, 'Mean') -c 7000 -u myuser -p awesomepassword

There are a few things to note.  The -s flag specifies which graphite server or endpoint to hit, -t specifies the target or the graphite query to run the script against, the -c flag sets the threshold, -u and -p are used if your Graphite server uses authentication.  If your Graphite instance is public it should probably use auth, otherwise if it is internal only, probably not as important.  Obviously these are just dummy values, included to give you a better idea of what a real command should look like.  Use your own values in their place.

The query we’re running is against a statsd metric that for mean response time for a request that gets recorded from the code (this is the developer instrumenting their code part I mentioned).  This check is specific to my environment so you will need to modify any of your queries to make sure to alert on a useful metric and threshold in your own environment.

Here’s an example of what the graphite graph (rendered in Grafana) looks like.

Sensu Graph

Obviously this is just a sample but it should give you the general idea of what to look for.

If you examine the script, there are a few Ruby Gem requirements to get the script to run, which you will need to be installed if you haven’t already.  They are sensu-plugin, json, json-uri and openssl.  You don’t need the sensu-plugin if you are just running the check manually but you WILL need to have it installed on the Sensu client that will be running the scheduled check.  That can be done manually or with the Sensu Chef recipe (specifically for turning on Sensu embedded ruby and ruby gems), which I recommend using anyway if you plan on doing any type of deployments at scale using Sensu.

Here is the Chef code looks like if you use Sensu to deploy this check automatically.

sensu_check "check_request_time" do 
  command "#{node['sensu']['plugindir']}/check-data.rb -s graphite.example.com -t \"alias(stats.timers.server.facedetection.response_time.mean, 'Mean')\" -c 7000 -a 360 -u myuser -p awesomepassword"
  handlers ["pagerduty", "slack"] 
  subscribers ["core"] 
  interval 60 
  standalone true 
  additional(:notification => "Request time above threshold", :occurrences => 5)
end

This should look familiar if you have any background using the Sensu Chef cookbook.  Basically we are using the sensu_check LWRP to execute the script with the different parameters we want, using the pagerduty and slack handlers, which are just fancy ways to pipe out the results of the check.  We are also saying we want to run this on a scheduled interval time of 60 seconds as a standalone check, which means it will be executed on the client node (not the Sensu server itself).  Finally, we are saying that after 5 failed checks we want to append a message to the handler that says what exactly is going wrong.

You can stick this logic in an existing recipe or create a new one that handles your metrics threshold checks.  I’m not sure what the best practice is for where to put the check but I have a recipe that runs standalone threshold checks that I stuck this logic in to and it seems to work.  Once the logic has been added you should be able to run chef-client for the new check to get picked up.

Read More

Descubre el Mundo de Casino JugaBet: Tu Guía Completa para JugaBet App y Juegos en Línea

En la era digital actual, el mundo de los juegos en línea está en constante evolución. Entre las diversas plataformas disponibles, JugaBet ha emergido como una opción destacada para los entusiastas de los casinos en línea. Desde su app innovadora hasta su amplia gama de juegos, JugaBet se está posicionando como un líder en la industria de apuestas. Acompáñanos mientras exploramos lo que la JugaBet app tiene para ofrecer.

Una Mirada a JugaBet Online

JugaBet online es una plataforma completa que ofrece una experiencia de juego inmersiva y segura. Con una interfaz intuitiva, tanto los nuevos jugadores como los experimentados encontrarán fácil sumergirse en la acción. Desde tragamonedas hasta juegos de mesa clásicos como el póker y la ruleta, JugaBet proporciona una oferta variada que asegura horas de entretenimiento.

Opciones de Juego en JugaBet

Características Destacadas de JugaBet Casino

  • Variedad de Juegos: JugaBet casino ofrece una extensa colección de juegos que se adaptan a todos los gustos. Desde emocionantes tragamonedas hasta juegos de mesa estratégicos, hay algo para todos.
  • Bono de Bienvenida: Para nuevos jugadores, el casino JugaBet ofrece atractivas bonificaciones que aumentan tus probabilidades de ganar.
  • Juego Seguro y Justo: Con licencias adecuadas y medidas de encriptación avanzadas, los jugadores pueden estar seguros de que su información está protegida.
  • Atención al Cliente: El soporte está disponible 24/7 para resolver cualquier consulta o problema que puedas tener.

La Experiencia en la JugaBet App

La JugaBet app está diseñada para brindar la máxima comodidad a los jugadores. Con su diseño optimizado para dispositivos móviles, puedes llevar la emoción del casino contigo dondequiera que vayas. La aplicación es compatible con Android y iOS y ofrece una experiencia de usuario fluida.

Conclusión

En resumen, JugaBet se presenta como una opción sólida para aquellos interesados en los casinos en línea. Con su diversidad de juegos, comodidad móvil a través de la app, y una experiencia segura, es fácil ver por qué cada vez más jugadores están optando por JugaBet casino. Si estás buscando emoción y entretenimiento garantizados, no busques más que JugaBet.

Video Introducción

Para ver más sobre cómo comenzar y explorar la plataforma, mira nuestro video de introducción a continuación:

Read More

Découvrez le Monde Passionnant de Stake: Application, Paris, Bonus et Casino en France

Stake Casino Image

Le monde du jeu en ligne a connu une révolution avec l’arrivée de nouvelles plateformes comme Stake, qui a rapidement conquis le public avec son interface innovante et ses offres alléchantes. Dans cet article, nous allons explorer les différentes facettes de cette plateforme passionnante, notamment l’application Stake, les paris Stake, les bonus Stake, et le casino Stake en France.

L’application Stake: Jouez où que vous soyez

L’application Stake offre une flexibilité incroyable aux utilisateurs, leur permettant de parier et de jouer à leur convenance depuis n’importe quel appareil mobile. L’interface utilisateur intuitive facilite la navigation, que vous soyez un joueur chevronné ou un débutant.

Les paris sur Stake: Une opportunité de gagner gros

Avec Stake Bet, les utilisateurs ont accès à un vaste éventail de paris sportifs et de jeux de casino. La plateforme propose des cotes compétitives et des paris en direct, ce qui ajoute une couche d’excitation supplémentaire pour ceux qui aiment être au cœur de l’action.

Bonus Stake: Maximisez vos chances de gagner

Les offres de Stake bonus sont parmi les plus généreuses du marché. Que vous soyez un nouveau joueur ou un habitué, Stake propose une variété de promotions et de bonus de bienvenue qui boostent vos fonds de jeu, augmentant ainsi vos chances de gagner des récompenses intéressantes.

Le casino Stake en France: Une expérience de jeu immersive

Le Stake casino en France offre une expérience de jeu immersive avec une vaste sélection de jeux, y compris les machines à sous, les jeux de table et même un casino en direct. Les joueurs français peuvent profiter de la plateforme en toute confiance grâce aux mesures de sécurité robustes mises en place.

Découvrez plus de détails sur Stake et commencez à explorer ses fonctionnalités dès aujourd’hui!

Conclusion

En résumé, Stake est une plateforme de jeu en ligne qui répond aux attentes des utilisateurs en matière de diversité de jeux, de confort grâce à son application, et de possibilités de gains grâce à ses bonus et paris. Pour quiconque souhaite plonger dans le monde du jeu numérique, Stake se présente comme une option incontournable.

Read More

Unlock the Thrills of Lucky Pays Casino: Login, Free Spins, and Bonuses!

Welcome to the world of Lucky Pays Casino, where entertainment meets opportunity and every login can lead to exciting rewards. Whether you’re a seasoned player or a curious newcomer, discovering what Lucky Pays has in store will enhance your online gaming experience.

Why Choose Lucky Pays Casino Online?

Lucky Pays Casino offers an array of games and features designed to give every player an unforgettable gaming journey. From free spins to amazing bonuses, the excitement never stops. Players are drawn to Lucky Pays for its user-friendly platform and reliable security, ensuring a safe and enjoyable experience.

Lucky Pays Casino Image

Getting Started: Lucky Pays Login

The first step to accessing the fun is an easy and quick Lucky Pays Casino Login. Just a few clicks on the Lucky Pays login portal, and you’re part of a stimulating universe filled with potential winnings and entertainment.

Exploring Bonuses and Free Spins

One of the elements that make Lucky Pays Casino online stand out is its lucrative bonuses. New and returning players can benefit from various promotions that boost their chances of winning. Free spins are a popular feature that enhances gameplay without additional risk.

Table of Exciting Features

Feature Description
Lucky Pays Free Spins Boost your gameplay with additional spins that come at no extra cost.
Bonuses From welcome bonuses to loyalty rewards, there’s always something to take advantage of.
Easy Login Seamless access to the platform with secure login credentials.

A Community of Winning

Beyond the games, Lucky Pays Casino fosters a community of players who are keen to share their strategies and successes. The vibrant forums and social media channels provide a platform for players to connect and learn from each other.

Join the Action Now

What are you waiting for? Dive into the excitement with Lucky Pays Casino, where every login is a step towards your next big win. Don’t miss out on the fun—log in today and experience the thrill firsthand.

Watch More: Understanding Casino Dynamics

Read More

Intro to Systemd

I have a rocky relationship with Systemd.  On the one hand I love how powerful and extensive it is.  On the other hand, I hate how cumbersome and clunky it can sometimes feel.  There are a TON of moving components and it is very confusing to use if you have no experience with it.  The aim of this post is NOT to debate relative merits of Systemd but instead to take users through a few basic examples of how to accomplish tasks with Systemd and get familiar with how to manage systems with this framework.

My background is primarily with Debian/Ubuntu so moving over to this init system has been a learning curve.  The problem I had when I first made the transition is that there aren’t a lot of great resources currently for making the change.

Most of my knowledge has been pieced together from various blog posts and sites, the best of which is over at the Arch wiki.  As Systemd continues to mature it is becoming increasingly easier to find good guides and resources but the Arch wiki is still the defacto, go to place to find resources about how to use Systemd.

Another thing that has helped is forcing myself to use CoreOS, which, for better or worse has forced me to learn how to use Systemd.  It seems that most modern Linux distro’s are moving towards Systemd, so it’s probably worth it to at least begin experimenting with it at this point.  Ubuntu 15.04 as well as Debian 8 have both made the jump, along with other RedHat based distro’s, with more to follow.

While the learning curve can be a little steep to start with, you can learn about 80% of the things that Systemd can do with about 20% of the effort.  Getting the basics down takes a little bit of effort but will more than be enough to manage a system.  Before starting, as a disclaimer, I do not claim to be an expert but I have learned the hard way how things work and sometimes don’t work with Systemd.

Basics of Systemd

So now that we have a little bit of background stuff out of the way, we can look at some of the meat and potatoes of Systemd.  The first thing to do is get an idea of what services are running on your system.

systemctl

This will give you a listing of everything running on your system.  Usually there are a very large number of units listed.  This isn’t really important but say for example, there is a failed unit.  You can filter systemctl to only spit out failed units.

systemctl --failed

That’s pretty cool.  If, for examle there is a failed unit file you can drill down in to that unit specifically.

systemctl status <unit>

This will give you process and service information for the unit file and the last 10 lines of logs for the unit as well, which can be really handy for troubleshooting.

One of the easier ways to work with unit files is to use the edit subcommand.  This method removes much of the complexity of having to know exactly where all of the unit files live on the system.

systemctl edit --full <unit>

You can manage and interact with Systemd and the unit files in a straight forward way.  We will examine a few examples.

systemctl start <unit> - start a stopped service
systemctl stop <unit> - stop a running service
systemctl restart <unit> - restart a service
systemctl disable <unit> - stop unit from loading on boot
systemctl enable <unit>  - load unit on boot

If you make a change to a service or unit file (we will go over this later) you need to reload the Systemd daemon for it to pick up the changes to the file.

sytemctl daemon-reload

This is super important (on CoreOS at least) when troubleshooting because if you don’t run the reload your process will not update and will not change its behavior.

There are many many more tips and tricks for working with systemctl but this should give users a basic grasp on interacting with components of the system.  Again, for lots more details I advise that you check out the wiki.

Journalctl

If you are coming from older Debian/Ubuntu distros you will need to get familiar with using journalctl to view and manipulate your log files.

One of the first changes that people notice right away is that there aren’t any beloved log files /var/log in Systemd any more.  Well, there are still logs, but it isn’t what most folks are used to.

The files haven’t gone away, they are simply disguised as a binary file and are accessible via journald.  To check how much space your logs are taking up on disk you can use the following command.

journalctl --disk-usage

Journalctl is a powerful tool for doing just about everything you can think of with log files.  Because journald writes logs as a binary file you need this tool to interact with them.  That’s okay though because journalctl has pretty much all of the features needed to look through logs with its built in flags.  For example, if you want to tail a log file, you can use the “-f” flag to follow “-u” to specify the systemd unit and the systemd unit name to follow it as illustrated below (this is a CoreOS system so your results may vary on a different OS).

journalctl -f -u motdgen

To follow all the entries that journalctl is picking up (pretty much just tailing all the logs as an equivalent) you can just use this.

journalctl -f

Sometimes you only want to view the last X number of entries in a log file.  To look at older entries you can use the “-n” flag.

journalctl -n 100 -u motdgen

You can filter logs to only show messages since the last boot.

journalctl -b

There are many more options and the filtering capabilities of journalctl are very powerful.  Additionally, journalctl offers JSON outputs, filtering by log priority, granular filtering by time with –unit and –since flags, filtering on different boots, and more.

I suggest exploring on your own a little bit to see how far the capabilities can go.  Here is a link to all of the various flags that journalctl has as well as a good writeup to get a good idea of some of the more advanced capabilities of journalctl.

Drop-in Units

Writing unit files is somewhat of an art form.  I feel that it can quickly become such a complicated topic that I won’t discuss it in full detail here.

By default, Systemd unit files are written to /usr/lib/systemd/system and custom defined unit files are written to /etc/systemd/system.  Systemd looks at both locations for which files to load up.  Because of this, you can extend base units that live in the /usr/lib path by augmenting them in /etc/systemd.

This has a few implications.  First, it makes management of unit files a little bit easier to work with.  It also makes extending units a little bit easier.  You don’t need to worry about manipulting the system level units, you just add functionality on top of them in /etc/systemd.

Drop-in units are a handy feature if you need to extend a basic unit.  To make the drop-in work, it must follow the format of /etc/systemd/system/unit.d/override.conf, where unit.d is the full name of the service that you are extending.

The following example extends the CoreOS baked in etcd2 service

/etc/systemd/system/etcd2.service.d/30-configuration.conf

[Service]
# General settings
Environment=ETCD_DEBUG=true

Replacing Cron

Well not exactly.  Systemd doesn’t use cron jobs so if you want to get something to run on a schedule you will need to use a timer unit and associate a service with it.

[Unit]
Description=Log file cleaner (runs daily at midnight)

[Timer]
OnCalendar=daily

Notice that there is a log-cleaner.timer as well as a log-cleaner.service (below).  The easiest way I have found is to create a service/timer pair, which ensures that the timer runs the service based on its schedule.

[Unit]
Description=Log file cleaner

[Service]
ExecStart=/usr/bin/bash -c "truncate -s 1m /data/*.log"

The only thing that the service is doing is running a shell command which will get run based on the timer directive in the timer unit file.

The timer directive in the timer unit is pretty flexible.  For example, you can tell the timer to run based on the calendar either by day, week or month or alternately you can have the unit run services based on the system time by seconds, minutes or hours.

One of the down sides of timers is that there is not an easy way to email results.  With cron this is easily configurable.  Likewise, timers don’t have a random delay to run jobs like cron has.  So, timers are definitely no replacement for cron but have a lot of usable functionality, it is just confusing to learn at first, especially if you are used to cron.

Here is more involved tutorial for working with timers.  Also, the Arch wiki once again is great and has a dedicated section for timers.

Conclusion

This introduction is really just the beginning.  There are so many more pieces to the Systemd puzzle, I have just covered the basics, in fact I have deliberately chosen not to cover many of the topics and concepts because they can convolute the learning process and slow down the knowledge.  I chose to focus instead on the most basic ideas that are used most frequently in day to day administration.  Feel free to go do your own research and play around with the more advanced topics.

Systemd aims to solve a lot of problems but brings about a lot of complexity as well to accomplish this task.  In my opinion it is definitely worth investing the time and energy to learn this system and service manager though, pretty much all the Linux distro’s are moving towards it in the future and you would be doing yourself a disservice by not learning it.

Other areas of Systemd that aren’t covered in this post but are worth researching and playing with are:

  • Targets (analogous to runlevels)
  • Managing NTP with timedateclt
  • Network management with networkd
  • Hostname management with hostnamectl
  • Username management with loginctl

One of the easiest ways to get started with systemd is by grabbing a Vagrant box that leverages Systemd.  I like the CoreOS Vagrant box but there are many other options for getting started.  One of the best tools for learning is by doing, so take some of these commands and resources and go start playing around with Systemd.  Feel free if you have any extra additions or need help getting started with Systemd.

Read More