Smart rules with Host Tags in Checkmk #CMKTutorial
Summary
TLDRDieses Video-Tutörial erläutert die Verwendung von Host-Tags und -Labels in Checkmk, um spezifische Regeln für Gruppen von Hosts zu erstellen. Es zeigt, wie man Tags und Labels beim Erstellen von Hosts zuweist und später in Regeln nutzt, um z.B. den CPU-Lastverbrauch von Datenbankservern in Produktionsumgebungen zu überwachen. Es vergleicht Tags mit Labels, erklärt die Vorteile und Nachteile beider und demonstriert, wie man benutzerdefinierte Tags erstellt und Regeln anhand dieser Tags und Labels anpasst. Der Fokus liegt auf der Präzision und Flexibilität, um Hosts effektiv zu verwalten.
Takeaways
- 📌 **Host-Tags und Labels**: Der zweite Teil der Trilogie erklärt, wie man Host-Tags und Labels verwendet, um spezifische Regeln für Gruppen von Hosts zu erstellen.
- 🔖 **Unterschied zwischen Tags und Labels**: Host-Tags sind vorkonfiguriert und haben Gruppen und Werte, während Labels frei form sind und keine Vorkonfiguration benötigen.
- 🛠️ **Anwendung von Host-Tags**: Host-Tags werden beim Erstellen von Hosts zugewiesen, um beispielsweise den Betriebsumfeld eines Hosts (Produktion oder Test) zu kennzeichnen.
- 📝 **Beispiel für Host-Tag-Verwendung**: Regeln können so eingerichtet werden, dass sie nur für Hosts mit bestimmten Host-Tags gelten, wie z.B. CPU-Auslastung für Datenbankserver.
- 🔄 **Erstellen von Regeln**: Regeln können basierend auf Host-Tags erstellt werden, um z.B. Warnungen bei einer CPU-Auslastung über 80% in Produktionssystemen zu erhalten.
- 📑 **Anpassung von Regeln**: Regeln können kopiert und angepasst werden, um sie für unterschiedliche Umgebungen (Produktion/Test) zu verwenden.
- 🆕 **Erstellen eigener Tag-Gruppen**: Statt vorkonfigurierten Host-Tags kann man eigene Tag-Gruppen erstellen, um Hosts nach Anwendungstyp zu kategorisieren.
- 🔄 **Ändern des Standard-Tags**: Es ist möglich, den Standardwert für ein Tag zu ändern, um sicherzustellen, dass neue Hosts korrekt kategorisiert werden.
- 📋 **Verwenden von Labels**: Labels können manuell hinzugefügt und in Regeln verwendet werden, um spezifische Host-Eigenschaften zu erfassen.
- 🔍 **Suche nach Regeln**: Regeln können über die Regelsuche in Checkmk gefunden und bearbeitet werden, um sie für bestimmte Host-Tags oder Labels zu konfigurieren.
- 🗂️ **Vorteile von Host-Stacks**: Durch die Verwendung von Host-Tags und Labels kann man allgemeine Regeln auf eine große Anzahl von Hosts anwenden, indem man nur die richtigen Tags setzt.
Q & A
Was wurde im ersten Teil der Trilogie über Regeln und Dienste besprochen?
-Im ersten Teil der Trilogie wurden Regeln und Schwellenwerte behandelt.
Was sind Host-Tags und wie werden sie verwendet?
-Host-Tags sind Bezeichnungen, die Hosts zuweisen, um sie in bestimmten Gruppen zu klassifizieren, z.B. nach der Umgebung (Produktion oder Test). Sie werden verwendet, um spezifische Regeln für diese Gruppen zu erstellen.
Was ist der Unterschied zwischen Host-Tags und Labels?
-Host-Tags bestehen aus einer vorkonfigurierten Gruppe von Werten, während Labels frei formgebend sind und keine vorherige Konfiguration erfordern.
Wie wird eine Regel für einen bestimmten Host mit Host-Tags erstellt?
-Man erstellt eine Regel und fügt Bedingungen hinzu, die auf bestimmte Host-Tags wie z.B. 'Produktive Systeme' abzielen.
Was sind die vorkonfigurierten Host-Tags, die von Checkmk bereitgestellt werden?
-Vorkonfigurierte Host-Tags in Checkmk umfassen z.B. 'Criticality' mit Werten wie 'Produktive System' und 'Test System'.
Wie kann man einen eigenen Tag-Gruppierung erstellen?
-Man geht zu 'Setup' > 'Tags' und erstellt eine neue Tag-Gruppe mit einer eindeutigen ID, einem Titel und mehreren Tag-Auswahlmöglichkeiten.
Welche Rolle spielen Labels in der Verwaltung von Hosts?
-Labels sind Schlüssel-Wert-Paare, die manuell hinzugefügt werden können und verwendet werden, um Regeln für Hosts zu erstellen, die diese spezifischen Labels haben.
Was passiert, wenn man einen Fehler in einem Label macht?
-Es gibt keine Schutzmechanismen gegen Tippfehler bei Labels, was zu Problemen führen kann, wenn Regeln darauf abzielen sollen.
Wie werden Regeln für Hosts mit bestimmten Labels erstellt?
-Man bearbeitet die Regel für einen Dienst eines Hosts und fügt eine Bedingung hinzu, die auf das Label hinweist, z.B. 'app:mysql'.
Welche Vor- und Nachteile hat die Verwendung von Host-Tags im Vergleich zu Labels?
-Host-Tags bieten mehr Sicherheit, da sie vorkonfiguriert sind und Tippfehler verhindern. Labels sind flexibler, können jedoch zu Tippfehlern führen.
Was wird im nächsten Teil der Videoserie behandelt?
-Im nächsten Teil der Serie werden Ordner und ihre Verwendung zur Gruppierung von Hosts erläutert.
Outlines
🔖 Host-Tags und Labels für spezifische Regelerstellung
Dieses Video-Skriptabschnitt erklärt, wie Host-Tags und Labels verwendet werden, um spezifische Regeln für Gruppen von Hosts zu erstellen. Es wird gezeigt, wie man Host-Tags wie 'Produktions-System' oder 'Test-System' zuweist, um beispielsweise CPU-Auslastungsregeln für Datenbankserver in einer Produktionsumgebung zu definieren. Zudem wird der Unterschied zwischen Host-Tags und Labels erläutert und wie man sie in Checkmk konfiguriert, um Regeln basierend auf diesen Tags anzuwenden.
🛠️ Erstellen und Anwenden eigener Host-Tag-Gruppen
In diesem Abschnitt wird gezeigt, wie man benutzerdefinierte Host-Tag-Gruppen erstellt, um Hosts anhand ihrer Anwendungstypen wie 'Web-Server' oder 'Datenbank-Server' zu kategorisieren. Es wird erklärt, wie man neue Tag-Gruppen mit eindeutigen IDs und Titeln erstellt, welcher Zweck sie erfüllen und wie man diese dann Hosts zuweist. Anschließend wird gezeigt, wie man auf diese Tags in Regeln zur Anwendung von Konfigurationen auf große Host-Gruppen abzielt.
📋 Verwendung von Labels für flexible Regelanwendung
Dieser Abschnitt behandelt Labels, die Checkmk zur flexiblen Anwendung von Regeln auf Hosts verwendet. Es wird erklärt, wie man Labels manuell hinzufügt, wie sie im System angezeigt werden und wie man Regeln basierend auf diesen Labels erstellt. Der Vorteil von Labels gegenüber Host-Tags ist ihre Flexibilität, allerdings besteht das Risiko von Tippfehlern, da sie nicht vorab konfiguriert werden müssen.
📝 Unterschied zwischen Host-Tags und Labels
Der vierte Abschnitt fasst den Unterschied zwischen Host-Tags und Labels zusammen. Während Host-Tags vorab konfiguriert werden müssen und somit weniger fehleranfällig sind, bieten Labels größere Flexibilität, sind jedoch anfälliger für Tippfehler. Es wird außerdem gezeigt, wie man beide Systeme kombiniert, um Regeln für Hosts mit spezifischen Eigenschaften anzuwenden, und wie man die Vorteile von Host-Stacks nutzt, um neue Hosts leichter zu konfigurieren.
Mindmap
Keywords
💡Regeln
💡Host-Tags
💡Labels
💡CPU-Auslastung
💡Produktionsumgebung
💡Testumgebung
💡Checkmk
💡Host-Gruppen
💡Regelbedingungen
💡Konfiguration
💡Docker
Highlights
Teil zwei einer Trilogie über Regeln und Dienste, Parameter.
Erste Videoteil über Regeln und Schwellenwerte.
Verwendung von Host-Tags und Labels für spezifische Host-Gruppen.
Beispiel für CPU-Last von Datenbankservern in Produktionsumgebung.
Zuordnung von Host-Tags/Labels zur Unterscheidung von Umgebungen.
Erstellung von Regeln basierend auf Host-Tags.
Hinzufügung von vier Dummy-Hosts zur Veranschaulichung.
Bearbeitung von Host-Attributen für die Zuweisung von Tags.
Vordefinierte Host-Tags wie 'Criticality' und deren Werte.
Erstellen von Regeln für CPU-Auslastung abhängig von der Umgebung.
Verwendung von Regelbedingungen für Host-Tags wie 'Produktivsystem'.
Erstellung von Regeln für Test-Systeme mit unerreichenbaren Schwellenwerten.
Anwendung von Host-Tags in Kombination mit Service-Regeln.
Empfehlung, eigene Tag-Gruppen zu erstellen statt vordefinierte zu verwenden.
Erstellung einer neuen Tag-Gruppe zur Beschreibung des Host-Typs.
Konfiguration von Hosts mit benutzerdefinierten Tags wie 'Web-Server' oder 'Datenbank-Server'.
Anpassung von Regeln, sodass sie nur für bestimmte Host-Typen gelten.
Unterschied zwischen Host-Tags und Labels hinsichtlich der Voraussetzungen und Anwendung.
Manuelles Hinzufügen von Labels und Erstellung von Regeln basierend auf diesen Labels.
Vorteile und Nachteile von Labels gegenüber Host-Tags.
Simultane Verwendung von Host-Tags und Labels in Regeln.
Vorschau auf das nächste Video zur Verwendung von Ordnern zur Gruppierung von Hosts.
Transcripts
Hello and welcome back to the second part of our trilogy about rules and service
parameters. In the first part, we talked about working with rules and
setting thresholds. And in this second part, I will take a look at host tags
and labels, and how you can use them to create rules for very specific
groups of hosts. For example to target the CPU load of all database servers
in a production environment.
Before we can create these specific rules we first have to be able to indicate whether
a host is, for example in a production or a test environment.
And we do that by assigning them host tags or labels.
The difference between the two you will learn in this video.
But for now, let's focus on host tags.
So the idea is that when we are creating a host
we immediately assign them certain tags or labels.
For example, if it's a test or a production system and later on when we create rules
we can say okay only apply this rule when the host has a certain tag for example
"the test environment".
Let me show you how that works.
As you can see I've added four more hosts to our system.
These are just dummy hosts for illustration purposes. For now, let's go to Setup
and Hosts, as you can see they all have the same IP address
but as I said they're for illustration purposes so that doesn't really matter.
Now let's edit the first one "dbserver1".
And we're only interested in this custom attribute section, so let's collapse the rest.
So as you can see there are some host tags pre-configured already by Checkmk.
For example, this one the Criticality, and you see that there's there are also some
values already pre-configured like 'Productive system', 'Test system'.
But we will pick 'Productive system' for now. Every host tag consists out of a Host group
which is this first part and the second part on the right,
the Value. Now let's save and go back to folder.
And also now let's do the same for the second one.
We're going to also make that a productive system.
As you can see the production system is the default value but
we're going to explicitly set it.
So save and go back to folder and now the second two so 'dbserver3' and '4' we want
to make a test system. And instead of repeating myself twice, I will just pre-select or
select both of them and go to hosts and edit attributes.
Now I will pick Criticality and, Test System > Save.
And I've added both at the same time. Okay, for now, we can just activate the changes.
And now these tags have been applied to all our database hosts and we can
define some rules based on these Host tags.
And the next thing we're going to do is create a rule or multiple rules because I want to
configure that I don't really care if the CPU utilization on the test systems reaches 100%.
But on the production systems, I want to get warned when they reach over 80%, so I
want to leave some headroom. Now let's go to one of our hosts. So, Monitor > all host.
And let's pick 'dbserver1'.
And we're interested in the CPU utilization. So let's go to parameters for this Service.
As you can see there are no rules set yet,
and we're going to create one now. So we are going to create a whole specific rule.
And under conditions we can remove the explicit host so we are not interested in specifically the
dbserver1, but rather in host tags, so we're going to add a host tag.
Namely the criticality that we just set, and then we create a condition so click on the
button add tag condition. And now it says criticality equals or is, 'Productive system'.
And you can pick another value here but I'll leave it at 'Productive system' for now.
And now we can set the actual values so undervalues we are going to pick
levels on total CPU utilization.
And we're picking fixed levels and we're going to change this to the Warning at 80%,
and Critical at 90%. And now we can save it and create a rule for our test systems,
and the easiest way to do that is by duplicating this one and then instead of
80% and 90% we are going to set it to 101% and 101% which are both levels
which cannot be reached so we should never see a Warning or a Critical state.
Then the only thing left to do is set this to 'Test system' and then we can save the changes.
Now you can see we have 2 rules here this one is green because we're still working
on dbserver1 which is a productive system so these conditions match.
And now we can just simply activate the changes.
And now we are using our host tags in combination with Service rules.
Like I said before these stack groups like Criticality are more of a pre-configured
example in Checkmk. So we recommend that you do not use these but rather that you
create your own and that's what I'm going to show you next.
Under setup, you can find an item called Tags and here you can find all pre-configured
tag groups. Some are built-in like these 4. but these 2 are more of an example and
that's why you can also delete them. I'm going to add a new tag group.
Every tag group has a required ID and a Title, the ID has to be unique
and cannot contain any spaces the title can be whatever you want it to be.
What we want to do is we want to create a tag group that illustrates or tells what
kind of application the host is. So, for example, is it a web server or a database server
and other. It doesn't cover everything here but it will illustrate what we want to showcase.
Okay, so now for the tag group id we're going to use 'application' (lowercase)
and for the title also 'Application' (but with a capital A).
Now this topic, and this tells you or this shows you when you're configuring a host and
which section the tag will appear. So I will create my own 'MyCustomTags'.
That way I can easily identify all my own customly created tags from all other tags.
Now every tag or tag group has one or multiple tag choices.
And these are the values which you can pick from when you are configuring a host.
So every tag also has a tag ID and these have to be unique within this tag group and
I will make three choices one will be web, this will be 'db' for 'database' and 'other'.
Now the title will be web servers 'Web Server', 'Database Server' and
once again 'Other'. The auxiliary tags we can forget for now.
You can change the order simply by dragging these up and down. but let's save.
So now every host will get a default value for the application tag that we just created.
And you see here that would be web server that would mean that every host would
be classified as a 'Web Server' so in our case it's probably best to set that to 'Other'.
So let's quickly change that. So here we're going to drag other to the top, and Save.
And now every host will be classified as other and only if we explicitly set it to
something else, it will be a 'Web Server' or 'Database server'.
Now we've created the tag but we are not actually using it.
So now the first thing we have to do is configure our host so they are using the tag.
So let's go to setup and host and we want to change these four database servers so
let's check them all here and edit them all at once. So hosts and then edit attributes
And now you see this new section here my custom tags and the default value is
'other' and we want to set that to 'Database server'.
So let's save this and activate all our changes.
And now all our database servers are classified as such.
Next thing to do is. go back to our rules and look at the two rules we previously
created and edit them in such a way that they will only apply to database servers.
Let me quickly show you another way to find rules if you go to setup and then rule search.
Then here under rules and then used ruleset.
Here you have an overview of all rulesets that have at least one rule in them.
Most of them have been pre-configured by Checkmk so that's why there are
already a quite a few in here. But if you know what you're looking for you can rather
quickly find what you need. So but of course if you know what you're looking for by
name then you can simply filter on it. So CPU. and now we are at CPU utilization.
So now let's edit both these rules so they will use the new tag we just created.
So let's click on edit and then under condition we can add a second host tag.
And we will add, 'application' and the value will be 'Database server'.
And we can save, and as you can see there is now a second condition here.
So a host has the criticality has to be 'Productive system'.
And the application has to be,
'Database Server'. Now let's apply the same thing to the test system.
So once again let's pick 'application'.
And add the condition database server and as you can see now we have 2 rules. Both for database
servers one for the productive environment and one for the test environment.
And with that, we have found an elegant way to apply general rules to a large number of hosts.
So now when you add a new host you just need to make sure that you set the right
tags or the values for the tags in order for the right configuration to be applied to it.
And that's the advantage of a host stack. Now a similar concept to host tags are 'labels'.
But in contrast to host tags, labels are freeform so that means you can add any
number of labels to a hos,t but and then later create rules that apply to these labels.
The only disadvantage is that there is nothing protecting you
from making typos when adding these labels. Labels can also be automatically imported by Checkmk.
For example when you monitor docker or some cloud service,
Checkmk can import these labels and apply them to your host when you create them.
So now let's add some labels manually. So to add a host label we don't have to
pre-configure anything we can simply go to setup,
hosts and let's add one for 'dbserver2' for example.
Now hereunder custom attribute, you have labels so if we check that we can add a label.
For example 'app:mysql', enter now it's important to know when you add a label you
have to add a colon. And they are written sort of as a key-value pair and what is before
the colon, the key is similar to a group when you add a host tag.
And what comes after the colon is the value.
And you can only add one label per group or per key so if I now were to add
'app123' then that should fill but I can add 'test123' for example.
Let's save this and go to folder.
Now we can also let the labels appear here, in this view to do that you go to display And check
this box show explicit host labels now you can see the labels here in the last column.
I can also create rules based on these labels. So, for example, let's edit the rule for
CPU utilization to do that let's go to: all hosts > dbserver2 > CPU utilization.
Let's edit that.
And now edit this rule.
So here we can now add a label condition so we can say has some label for example
'app:mysql'.
And if I now save it you see that there is now a third condition. So this rule will now only
apply when it's a database server and it has the criticality tag, 'productive system'
, and it has the 'app:mysql' host label.
Now you know the difference between host tags and labels.
Labels are very easy to apply and you don't need to pre-configure anything but they
have the disadvantage that they do not protect you against typos. So if you have a
very strict setting or very strict settings and you want to only apply rules to hosts
with very specific properties and you want to have the safety that colleagues do not make
typos when adding labels then host tags are probably the right choice for you.
But if you like living on the edge or you want to use the labels that Checkmk
automatically recognizes and apply for you then labels can be an interesting choice.
And of course, you can use both at the same time like I just showed you.
So that was it for this part and in the next part I'm going to show you folders and
how you can use them to group your host together. If this video was helpful to you,
please drop a like and subscribe to the channel. See you in the next part
Browse More Related Video
Suno Prompting SECRETS! Powerful Metatags That Transform Your AI Music!
Crashkurs für Anfänger | Canva Tutorial Deutsch
Wie du Trello als CRM und Sales-Pipeline für dein Unternehmen verwendest (auf deutsch)
Dominate Etsy with Email Marketing Tactics - Part 3/4
5 Quick SEO Hacks You're Missing Right Now
Day 3: Learn How to Produce Music (How to Lay Down Drums)
5.0 / 5 (0 votes)