Wednesday, July 6, 2022
  • Login
  • Register
IT Skills You Need
  • Home
  • Monitoring
  • DevOps
  • AI
  • Big-data
  • Automation
  • Agile
  • ITIL
  • AIOps
No Result
View All Result
  • Home
  • Monitoring
  • DevOps
  • AI
  • Big-data
  • Automation
  • Agile
  • ITIL
  • AIOps
No Result
View All Result
IT Skills You Need
No Result
View All Result
Home Monitoring

Simplifying Zabbix API workflows with named Zabbix API tokens

admin by admin
11 November 2021
in Monitoring
0 0
0
Simplifying Zabbix API workflows with named Zabbix API tokens
0
SHARES
3
VIEWS
Share on FacebookShare on Twitter

Zabbix API enables you to collect any and all information from your Zabbix instance by using a multitude of API methods. You can even utilize Zabbix API calls in your HTTP items. For example, this can be used to monitor the number of particular sets of metrics and visualize their growth over time. With named Zabbix API tokens, such use cases are a lot more simple to implement.

Before Zabbix 5.4 we had to perform the user.login API call to obtain the authentication token. Once the user session was closed, we had to relog, obtain the new authentication token and use it in the subsequent API calls.

With the pre-defined named Zabbix API tokens, you don’t have to constantly check if the authentication token needs to be updated. Starting from Zabbix 5.4 you can simply create a new named Zabbix API token with an expiration date and use it in your API calls.

Creating a new named Zabbix API token

The Zabbix API token creation process is extremely simple. All you have to do is navigate to Administration – General – API tokens and create a new API token. The named API tokens are created for a particular user and can have an optional expiration date and time – otherwise, the tokens are defined without an expiry date.

You can create a named API token in the API tokens section, under Administration – General

Once the Token has been created, make sure to store it somewhere safe, since you won’t be able to recover it afterward. If the token is lost – you will have to recreate it.

Make sure to store the auth token!

Don’t forget, that when defining a role for the particular API user, we can restrict which API methods this user has access to.

Simplifying API tasks with the named API token

There are many different use cases where you could implement Zabbix API calls to collect some additional information. For this blog post, I will create an HTTP item that uses item.get API call to monitor the number of unsupported items.

To achieve that, I will create an HTTP item on a host (This can be the default Zabbix server host or a host dedicated to collecting metrics via Zabbix API calls) and provide the API call in the request body. Since the named API token now provides a static authentication token until it expires, I can simply use it in my API call without the need to constantly keep it updated.

An HTTP agent item that uses a Zabbix API call in its request body

{
    "jsonrpc": "2.0",
    "method": "item.get",
    "params": {
			"countOutput":"1",
			 "filter": {
 "state": "1"
 }
    },
    "id": 2,
    "auth": "b72be8cf163438aacc5afa40a112155e307c3548ae63bd97b87ff4e98b1f7657"
}

HTTP item request body, which returns a count of unsupported items

I will also use regular expression preprocessing to obtain the numeric value from the API call result – otherwise, we won’t be able to graph our value or calculate trends for it.

Regular expression preprocessing step to obtain a numeric value from our Zabbix API call result

Utilizing Zabbix API scripts in Actions

In one of our previous blog posts, we covered resolving problems automatically with the event.acknowledge API method. The logic defined in the blog post was quite complex since we needed to keep an eye out for the authentication tokens and use a custom script to keep them up to date. With named Zabbix API tokens, this use case is a lot more simple.

All I have to do is create an Action operation script containing my API call and pass it to an action operation.

Action operation script that invokes Zabbix event.acknowledge API method

curl -sk -X POST -H "Content-Type: application/json" -d "
{
"jsonrpc": "2.0",
"method": "event.acknowledge",
"params": {
"eventids": "{EVENT.ID}",
"action": 1,
"message": "Problem resolved."
},
"auth": "<Place your authentication token here>",
"id": 2
}" <Place your Zabbix API endpoint URL here>

Problem remediation script example

Now my problems will get closed automatically after the time period which I have defined in my action.

Action operation which runs our event.acknowledge Zabbix API script

These are but a few examples that we can now achieve by using API tokens. A lot of information can be obtained and filtered in a unique way via Zabbix API, thus providing you with a granular analysis of your monitored environment. If you have recently upgraded to Zabbix 5.4 or plan to upgrade to Zabbix 6.0 LTS in the future, I would recommend implementing named Zabbix API tokens to simplify your day-to-day workflow and consider the possibilities that this new feature opens up for you.

If you have any questions or if you wish to share your particular use case for data collection or task automation with Zabbix API – feel free to share them in the comments section below!

Tags: AutomationDevOpsMonitoring

Get real time update about this post categories directly on your device, subscribe now.

Unsubscribe
Database Activity Monitoring – A Security Investment That Pays Off

Database Activity Monitoring – A Security Investment That Pays Off

20 February 2022
What’s Next for Automation 360 and Google Cloud

What’s Next for Automation 360 and Google Cloud

12 October 2021
AI Advances Help Contextual Targeted Advertising Strengthen Branding

AI Advances Help Contextual Targeted Advertising Strengthen Branding

29 October 2021
The ultimate guide to Twitter advanced search

The ultimate guide to Twitter advanced search

7 February 2022
An Overview of Data Collection: Data Sources and Data Mining

An Overview of Data Collection: Data Sources and Data Mining

10 March 2022
How To Use Jira To Support Your User Segmentation Strategy

How To Use Jira To Support Your User Segmentation Strategy

28 January 2021
Cryptocurrency Price Prediction using ARIMA Model

Cryptocurrency Price Prediction using ARIMA Model

3 December 2021

How to make your Twitter memes accessible for screen readers

8 November 2021

Color Picker Application Using Computer Vision

24 February 2022

Trends in AI and ML Healthcare Markets

14 December 2021

Master Natural Language Processing in 2022 with Best Resources

28 January 2022

Successful Data Science Initiatives: 5 Key Building Blocks

12 April 2021

How to make an invoice (with free invoice template)

20 April 2022

How I increased productivity by tracking my mental health

31 May 2022

Interoperability and RPA in Healthcare

15 March 2022

Search for Opportunities or Automate the Biggest Pains? It Depends

1 September 2021
IT Skills You Need

© 2022 IT SKILLS YOU NEED

Navigate Site

  • Activity
  • Classifieds
  • Groups
  • Home
  • Members

Follow Us

No Result
View All Result
  • Home

© 2022 IT SKILLS YOU NEED

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms bellow to register

*By registering into our website, you agree to the Terms & Conditions and Privacy Policy.
All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In

Add New Playlist

This website uses cookies. By continuing to use this website you are giving consent to cookies being used. Visit our Privacy and Cookie Policy.