Details

    • Type: New Feature Request New Feature Request
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0.0alpha5
    • Component/s: API (A)
    • Labels:

      Description

      Zabbix API should support trends.get method like history.get.

        Issue Links

          Activity

          Hide
          Noah Leaman added a comment -

          I need this in order to create a custom dashboard. Related, but a different reqest would be to have an API call returns values from both history and/or trends based on the date range requested and what the retention settings are.

          Show
          Noah Leaman added a comment - I need this in order to create a custom dashboard. Related, but a different reqest would be to have an API call returns values from both history and/or trends based on the date range requested and what the retention settings are.
          Hide
          Łukasz Jernaś added a comment -

          Any ETA on this maybe?

          Show
          Łukasz Jernaś added a comment - Any ETA on this maybe?
          Hide
          richlv added a comment -

          it's currently not on the roadmap. there have been some discussions about financing such development, but nothing specific

          Show
          richlv added a comment - it's currently not on the roadmap. there have been some discussions about financing such development, but nothing specific
          Hide
          D.Spindel Ljungmark added a comment -

          This is a patch against Zabbix 2.0.8 PHP frontend that implements trends API.

          CTrends.php is originally a copy of CHistory.php.

          trends API retains the same API as history.

          cp CHistory.php CTrends.php
          git apply 0001-Initial-support-for-Trends-API.patch

          Show
          D.Spindel Ljungmark added a comment - This is a patch against Zabbix 2.0.8 PHP frontend that implements trends API. CTrends.php is originally a copy of CHistory.php. trends API retains the same API as history. cp CHistory.php CTrends.php git apply 0001-Initial-support-for-Trends-API.patch
          Hide
          A B added a comment -

          Updated patch for zabbix 2.2.2.

          Show
          A B added a comment - Updated patch for zabbix 2.2.2.
          Hide
          Mattias Geniar added a comment -

          Both patches in this issue are confirmed to be working. Would there be any reason not to implement them?

          Show
          Mattias Geniar added a comment - Both patches in this issue are confirmed to be working. Would there be any reason not to implement them?
          Hide
          Alexei Vladishev added a comment -

          It will be implemented on Zabbix Server side, depends on ZBXNEXT-2519.

          Show
          Alexei Vladishev added a comment - It will be implemented on Zabbix Server side, depends on ZBXNEXT-2519 .
          Hide
          Yannick Moussette added a comment -

          I know that you guys are really busy, but does this have to wait on ZBXNEXT-2519? As it's only a new file added (doesn't break anything) and 3 new lines in API.php...?

          That being said, no disrespect intended, we do appreciate all your hard work!

          Show
          Yannick Moussette added a comment - I know that you guys are really busy, but does this have to wait on ZBXNEXT-2519 ? As it's only a new file added (doesn't break anything) and 3 new lines in API.php...? That being said, no disrespect intended, we do appreciate all your hard work!
          Hide
          Marc added a comment -
          Show
          Marc added a comment - The file zbxNext1193-2.2.8.patch is a refactored version of Initial-support-for-Trends-API-zbx-2.2.patch .
          Hide
          jaseywang added a comment -

          trends.get api is quite useful for users to custom their own dashboard, now, We have to get trends from MySQL

          Show
          jaseywang added a comment - trends.get api is quite useful for users to custom their own dashboard, now, We have to get trends from MySQL
          Hide
          Michel Marinho added a comment -

          This patch will work on Zabbix 2.4.x ? someone tried?

          I do not have access to the mysql database .

          Show
          Michel Marinho added a comment - This patch will work on Zabbix 2.4.x ? someone tried? I do not have access to the mysql database .
          Hide
          Yannick Moussette added a comment -

          I have one that works with 2.4.4, the 2.2 patch hadn't worked for me, so I made the manual changes, partially based on what was in the Patch.

          Interested?

          G.

          Show
          Yannick Moussette added a comment - I have one that works with 2.4.4, the 2.2 patch hadn't worked for me, so I made the manual changes, partially based on what was in the Patch. Interested? G.
          Hide
          Michel Marinho added a comment -

          of course yes,

          Could You send it to me ? I updated to 2.4.5 , and will test .

          thank you

          Show
          Michel Marinho added a comment - of course yes, Could You send it to me ? I updated to 2.4.5 , and will test . thank you
          Hide
          Yannick Moussette added a comment - - edited

          CTrend_for_Zabbix_2_4_4.zip --> Frontend new CTrend.php, modified API.php and CApiServiceFactory, for Zabbix 2.4.4 "Trend API".

          Show
          Yannick Moussette added a comment - - edited CTrend_for_Zabbix_2_4_4.zip --> Frontend new CTrend.php, modified API.php and CApiServiceFactory, for Zabbix 2.4.4 "Trend API".
          Hide
          Yannick Moussette added a comment - - edited

          Hi Michel,

          here's a zip file (CTrend_for_Zabbix_2_4_4.zip) containing the 3 php files I modified under Zabbix 2.4.4 to have the "Trend" API implemented.

          G.

          Show
          Yannick Moussette added a comment - - edited Hi Michel, here's a zip file (CTrend_for_Zabbix_2_4_4.zip) containing the 3 php files I modified under Zabbix 2.4.4 to have the "Trend" API implemented. G.
          Hide
          Holger Gruber added a comment -

          Hi Yannick,

          thanks for the patch, it's working fine for me. One thing:
          the 2.2 patch provides trends.get() while yours provides trend.get().
          As my project https://github.com/hgruber/zabbix-d3js-widgets uses trends.get() I would appreciate some consistency.

          Show
          Holger Gruber added a comment - Hi Yannick, thanks for the patch, it's working fine for me. One thing: the 2.2 patch provides trends.get() while yours provides trend.get(). As my project https://github.com/hgruber/zabbix-d3js-widgets uses trends.get() I would appreciate some consistency.
          Hide
          Yannick Moussette added a comment -

          Hi Holger,

          Well, considering that all the Zabbix API Classes are in singular format (host.get, hostgroup.get, history.get) and not plural, it made sense to me to follow the Zabbix SIA standard and name it "trend.get" instead of "trends.get"...

          However, since you have access to the modifications I uploaded, you can go ahead and change it to trends.get if you'd like, that's what Open source is all about.

          Please note that I'm not in any way part of the Zabbix SIA company, and that the patch I provided here is the one I use at my company for Zabbix 2.4.4, and shared here to help a fellow Zabbix User.

          G.

          Show
          Yannick Moussette added a comment - Hi Holger, Well, considering that all the Zabbix API Classes are in singular format (host.get, hostgroup.get, history.get) and not plural, it made sense to me to follow the Zabbix SIA standard and name it "trend.get" instead of "trends.get"... However, since you have access to the modifications I uploaded, you can go ahead and change it to trends.get if you'd like, that's what Open source is all about. Please note that I'm not in any way part of the Zabbix SIA company, and that the patch I provided here is the one I use at my company for Zabbix 2.4.4, and shared here to help a fellow Zabbix User. G.
          Hide
          Marc added a comment - - edited

          Considering the fact that the corresponding database table holds trends (min/max/avg) per item, the plural form sounds valid to me:

          zabbix=# \x
          Expanded display is on.
          zabbix=# SELECT * FROM trends LIMIT 1;
          -[ RECORD 1 ]---------
          itemid    | 616279
          clock     | 1398873600
          num       | 4
          value_min | 781.0000
          value_avg | 12338.7500
          value_max | 16440.0000
          
          zabbix=#
          

          Edit:
          Well, min/max/avg are actually no trends.by themselves. Anyway, since the table and everywhere else the term "trends" is used, I'd still vote for the plural form.
          Nevertheless, thanks a lot for porting the patch to 2.4!

          Show
          Marc added a comment - - edited Considering the fact that the corresponding database table holds trends (min/max/avg) per item, the plural form sounds valid to me: zabbix=# \x Expanded display is on. zabbix=# SELECT * FROM trends LIMIT 1; -[ RECORD 1 ]--------- itemid | 616279 clock | 1398873600 num | 4 value_min | 781.0000 value_avg | 12338.7500 value_max | 16440.0000 zabbix=# Edit: Well, min/max/avg are actually no trends.by themselves. Anyway, since the table and everywhere else the term "trends" is used, I'd still vote for the plural form. Nevertheless, thanks a lot for porting the patch to 2.4!
          Hide
          Yannick Moussette added a comment -

          Hi Marc,

          well, the "item_s_" table has a singular "host.get" API call, so does the "hosts" table, "groups" table, and the API calls are all singular...

          In any case, the main point is that there is now a "workaround", and that if the naming of the API items doesn't match your requirements, you can make the changes you need.

          Ultimately, this naming convention will be resolved when the guys from Zabbix SIA come up with the official Trend(s) API.

          Have a nice day!

          G.

          Show
          Yannick Moussette added a comment - Hi Marc, well, the "item_s_" table has a singular "host.get" API call, so does the "hosts" table, "groups" table, and the API calls are all singular... In any case, the main point is that there is now a "workaround", and that if the naming of the API items doesn't match your requirements, you can make the changes you need. Ultimately, this naming convention will be resolved when the guys from Zabbix SIA come up with the official Trend(s) API. Have a nice day! G.
          Hide
          Diwahar added a comment -

          Hi all,

          Can anyone provide an example for using "trends.get" api in zabbix?

          Thanks for the help.

          Show
          Diwahar added a comment - Hi all, Can anyone provide an example for using "trends.get" api in zabbix? Thanks for the help.
          Hide
          Marc added a comment -

          Actually the same way as history.get().

          Show
          Marc added a comment - Actually the same way as history.get().
          Hide
          John Green added a comment - - edited

          In the comment above by D.Spindel Ljungmark, there is a reference to Zabbix 2.0.8 PHP frontend and the CHistory.php in that version. Where can I find that source code, or alternatively, is it possible to get a final version of the CTrends.php file rather than patches, please?

          Update: On reviewing the attachment, zbxNext1193-2.2.8.patch, I found that it describes the final CTrends.php file and the change needed to API.php, and they compare well with the version I'm testing against which is 2.2.2, so I no longer require the final files. I have also installed and tested the changes and they work. I thought I'd leave this post to help anyone else struggling to work out what to use.

          Show
          John Green added a comment - - edited In the comment above by D.Spindel Ljungmark , there is a reference to Zabbix 2.0.8 PHP frontend and the CHistory.php in that version. Where can I find that source code, or alternatively, is it possible to get a final version of the CTrends.php file rather than patches, please? Update: On reviewing the attachment, zbxNext1193-2.2.8.patch, I found that it describes the final CTrends.php file and the change needed to API.php, and they compare well with the version I'm testing against which is 2.2.2, so I no longer require the final files. I have also installed and tested the changes and they work. I thought I'd leave this post to help anyone else struggling to work out what to use.
          Hide
          julian added a comment - - edited

          Hi all,

          Im using the PhpZabbixApi https://github.com/confirm/PhpZabbixApi library to use the API with PHP, now I need to get trends from the Api
          so installed the CTrend Patch. At the moment it isn't working, I don't know how to add the trend to
          the PHPApi Library can someone help me?

          Show
          julian added a comment - - edited Hi all, Im using the PhpZabbixApi https://github.com/confirm/PhpZabbixApi library to use the API with PHP, now I need to get trends from the Api so installed the CTrend Patch. At the moment it isn't working, I don't know how to add the trend to the PHPApi Library can someone help me?
          Hide
          Jim Druce added a comment -

          I know this is going to sound like a stupid question, but i'm running Zabbix 2.2.7 and would like to install this patch... I'm just not quite clear on how.. Do i put in the Zabbix_2.4.4 files i'm assuming not as i'm not on that version unless they are backward compatible... Can anyone give me some simple pointers... I'm trying to get Trend data through Grafana and get all the other bits other than this element...

          Show
          Jim Druce added a comment - I know this is going to sound like a stupid question, but i'm running Zabbix 2.2.7 and would like to install this patch... I'm just not quite clear on how.. Do i put in the Zabbix_2.4.4 files i'm assuming not as i'm not on that version unless they are backward compatible... Can anyone give me some simple pointers... I'm trying to get Trend data through Grafana and get all the other bits other than this element...
          Hide
          Yannick Moussette added a comment -

          Hi Jim,

          before making any changes, make sure you take a good backup of the "/usr/share/zabbix" directory (where the web/php/api files reside).
          tar cvfz ~/zabbix_www_backup.20151114.tar.gz /usr/share/zabbix

          next, download the zbxNext1193-2.2.8.patch, copy it to the /usr/share/zabbix directory, and apply the patch as follows:

          "patch -p0 < zbxNext1193-2.2.8.patch"

          This should make the necessary modifications to your files, and exposed a new Trend API.

          Notes: 1- the patch mentioned above is for 2.2.8. Might work for 2.2.7 as is, hence the backup procedure.
          2- you probably need to use "sudo" with the above commands, since the default package installation have the files belonging to root:root.

          I've set up a quick, 2.2.10 environment to test the above (can't download 2.2.7 anymore), but hopefully this should work.

          Good Luck!

          G.

          Show
          Yannick Moussette added a comment - Hi Jim, before making any changes, make sure you take a good backup of the "/usr/share/zabbix" directory (where the web/php/api files reside). tar cvfz ~/zabbix_www_backup.20151114.tar.gz /usr/share/zabbix next, download the zbxNext1193-2.2.8.patch, copy it to the /usr/share/zabbix directory, and apply the patch as follows: "patch -p0 < zbxNext1193-2.2.8.patch" This should make the necessary modifications to your files, and exposed a new Trend API. Notes: 1- the patch mentioned above is for 2.2.8. Might work for 2.2.7 as is, hence the backup procedure. 2- you probably need to use "sudo" with the above commands, since the default package installation have the files belonging to root:root. I've set up a quick, 2.2.10 environment to test the above (can't download 2.2.7 anymore), but hopefully this should work. Good Luck! G.
          Hide
          Jim Druce added a comment -

          Many thanks Yannick patch installed happily... and both files updated ok...

          Strangely now getting this error when enabling trends in Grafana in the graphs... I'm assuming i might need to upgrade the Zabbix environment to 2.2.8 as a minimum...

          Message:
          Cannot read property 'itemid' of undefined

          Stack trace:
          TypeError: Cannot read property 'itemid' of undefined

          Show
          Jim Druce added a comment - Many thanks Yannick patch installed happily... and both files updated ok... Strangely now getting this error when enabling trends in Grafana in the graphs... I'm assuming i might need to upgrade the Zabbix environment to 2.2.8 as a minimum... Message: Cannot read property 'itemid' of undefined Stack trace: TypeError: Cannot read property 'itemid' of undefined
          Hide
          Ivo Kurzemnieks added a comment -
          Show
          Ivo Kurzemnieks added a comment - Specification
          Hide
          Ivo Kurzemnieks added a comment -

          RESOLVED in svn://svn.zabbix.com/branches/dev/ZBXNEXT-1193

          Show
          Ivo Kurzemnieks added a comment - RESOLVED in svn://svn.zabbix.com/branches/dev/ZBXNEXT-1193
          Hide
          Daniel Nhoque Ruffato added a comment -

          Hi Yannick, please, could make the file available to me? I did not find for download ..

          Thank you!

          Show
          Daniel Nhoque Ruffato added a comment - Hi Yannick, please, could make the file available to me? I did not find for download .. Thank you!
          Hide
          Yannick Moussette added a comment -

          Hi Daniel,

          the files are at the top of this ZBXNEXT request, in the "Attachments" section.

          G.

          Show
          Yannick Moussette added a comment - Hi Daniel, the files are at the top of this ZBXNEXT request, in the "Attachments" section. G.
          Hide
          Daniel Nhoque Ruffato added a comment -

          Thank you for quick response and work! Found the files ... Now I must put them in the / usr / share / zabbix / include / classes / api #?

          Show
          Daniel Nhoque Ruffato added a comment - Thank you for quick response and work! Found the files ... Now I must put them in the / usr / share / zabbix / include / classes / api #?
          Hide
          Yannick Moussette added a comment -

          I'm guessing you're installing for Zabbix 2.4.4? If so, replace the files with the ones in the 2.4.4 zip file, only the CTrend.php file is new, and must be put in the same directory as CItem.php.

          As always, it's good practice to keep a backup/copy of the original files you will be replacing, just in case.

          G.

          Show
          Yannick Moussette added a comment - I'm guessing you're installing for Zabbix 2.4.4? If so, replace the files with the ones in the 2.4.4 zip file, only the CTrend.php file is new, and must be put in the same directory as CItem.php. As always, it's good practice to keep a backup/copy of the original files you will be replacing, just in case. G.
          Hide
          Alexander Vladishev added a comment -

          Successfully tested! Take a look at my changes in r57101.

          Show
          Alexander Vladishev added a comment - Successfully tested! Take a look at my changes in r57101.
          Hide
          Ivo Kurzemnieks added a comment - - edited

          (1) No translation string changes.

          Alexander Vladishev CLOSED

          Show
          Ivo Kurzemnieks added a comment - - edited (1) No translation string changes. Alexander Vladishev CLOSED
          Hide
          Ivo Kurzemnieks added a comment - - edited

          (2) As of r57101 when no parameters are given, no values are returned.

          Alexander Vladishev RESOLVED in r57112

          Ivo Kurzemnieks Thanks!
          CLOSED

          Show
          Ivo Kurzemnieks added a comment - - edited (2) As of r57101 when no parameters are given, no values are returned. Alexander Vladishev RESOLVED in r57112 Ivo Kurzemnieks Thanks! CLOSED
          Hide
          Ivo Kurzemnieks added a comment -

          Implemented in pre-3.0.0alpha5 (trunk) r57114

          Show
          Ivo Kurzemnieks added a comment - Implemented in pre-3.0.0alpha5 (trunk) r57114
          Show
          Ivo Kurzemnieks added a comment - - edited (3) API documentation updated: https://www.zabbix.com/documentation/3.0/manual/api/reference/trend https://www.zabbix.com/documentation/3.0/manual/api/reference/trend/object https://www.zabbix.com/documentation/3.0/manual/api/reference/trend/get https://www.zabbix.com/documentation/3.0/manual/api/changes_2.4_-_3.0 Alexander Vladishev CLOSED Glebs Ivanovskis Line "Return 10 latest values received from a numeric(float) item." here looks suspicious. Alexander Vladishev Thanks! I've removed the sentence. CLOSED
          Hide
          Alexander Vladishev added a comment - - edited

          (4) Documentation:

          Alexander Vladishev RESOLVED

          Martins Valkovskis Reviewed. CLOSED.

          Show
          Alexander Vladishev added a comment - - edited (4) Documentation: What's new in Zabbix 3.0.0 Alexander Vladishev RESOLVED Martins Valkovskis Reviewed. CLOSED.
          Hide
          clems94 added a comment -

          Hi all

          I installed the patch but i can not see the trends via Grafana 2.5.0.

          Could you help me ?

          Show
          clems94 added a comment - Hi all I installed the patch but i can not see the trends via Grafana 2.5.0. Could you help me ?
          Hide
          Andrei Gushchin added a comment - - edited

          This implementation doesn't work with Oracle DB backend, reported in ZBX-13325

          Show
          Andrei Gushchin added a comment - - edited This implementation doesn't work with Oracle DB backend, reported in ZBX-13325

            People

            • Assignee:
              Unassigned
              Reporter:
              Alexey Pustovalov
            • Votes:
              43 Vote for this issue
              Watchers:
              43 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: