graph.get

Description

integer/array graph.get(object **parameters**)

The method allows to retrieve graphs according to the given parameters.

This method is available to users of any type. Permissions to call the method can be revoked in user role settings. See User roles for more information.

Parameters

(object) Parameters defining the desired output.

The method supports the following parameters.

ParameterTypeDescription
graphidsstring/arrayReturn only graphs with the given IDs.
groupidsstring/arrayReturn only graphs that belong to hosts in the given host groups.
templateidsstring/arrayReturn only graph that belong to the given templates.
hostidsstring/arrayReturn only graphs that belong to the given hosts.
itemidsstring/arrayReturn only graphs that contain the given items.
templatedbooleanIf set to true return only graphs that belong to templates.
inheritedbooleanIf set to true return only graphs inherited from a template.
expandNameflagExpand macros in the graph name.
selectGroupsqueryReturn a groups property with the host groups that the graph belongs to.
selectTemplatesqueryReturn a templates property with the templates that the graph belongs to.
selectHostsqueryReturn a hosts property with the hosts that the graph belongs to.
selectItemsqueryReturn an items property with the items used in the graph.
selectGraphDiscoveryqueryReturn a graphDiscovery property with the graph discovery object. The graph discovery objects links the graph to a graph prototype from which it was created.

It has the following properties:
graphid - (string) ID of the graph;
parent_graphid - (string) ID of the graph prototype from which the graph has been created.
selectGraphItemsqueryReturn a gitems property with the items used in the graph.
selectDiscoveryRulequeryReturn a discoveryRule property with the low-level discovery rule that created the graph.
filterobjectReturn only those results that exactly match the given filter.

Accepts an array, where the keys are property names, and the values are either a single value or an array of values to match against.

Supports additional filters:
host - technical name of the host that the graph belongs to;
hostid - ID of the host that the graph belongs to.
sortfieldstring/arraySort the result by the given properties.

Possible values are: graphid, name and graphtype.
countOutputbooleanThese parameters being common for all get methods are described in detail in the reference commentary page.
editableboolean
excludeSearchboolean
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean

Return values

(integer/array) Returns either:

  • an array of objects;

  • the count of retrieved objects, if the countOutput parameter has been used.

Examples

Retrieving graphs from hosts

Retrieve all graphs from host “10107” and sort them by name.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "graph.get",
  4. "params": {
  5. "output": "extend",
  6. "hostids": 10107,
  7. "sortfield": "name"
  8. },
  9. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  10. "id": 1
  11. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "graphid": "612",
  6. "name": "CPU jumps",
  7. "width": "900",
  8. "height": "200",
  9. "yaxismin": "0.0000",
  10. "yaxismax": "100.0000",
  11. "templateid": "439",
  12. "show_work_period": "1",
  13. "show_triggers": "1",
  14. "graphtype": "0",
  15. "show_legend": "1",
  16. "show_3d": "0",
  17. "percent_left": "0.0000",
  18. "percent_right": "0.0000",
  19. "ymin_type": "0",
  20. "ymax_type": "0",
  21. "ymin_itemid": "0",
  22. "ymax_itemid": "0",
  23. "flags": "0"
  24. },
  25. {
  26. "graphid": "613",
  27. "name": "CPU load",
  28. "width": "900",
  29. "height": "200",
  30. "yaxismin": "0.0000",
  31. "yaxismax": "100.0000",
  32. "templateid": "433",
  33. "show_work_period": "1",
  34. "show_triggers": "1",
  35. "graphtype": "0",
  36. "show_legend": "1",
  37. "show_3d": "0",
  38. "percent_left": "0.0000",
  39. "percent_right": "0.0000",
  40. "ymin_type": "1",
  41. "ymax_type": "0",
  42. "ymin_itemid": "0",
  43. "ymax_itemid": "0",
  44. "flags": "0"
  45. },
  46. {
  47. "graphid": "614",
  48. "name": "CPU utilization",
  49. "width": "900",
  50. "height": "200",
  51. "yaxismin": "0.0000",
  52. "yaxismax": "100.0000",
  53. "templateid": "387",
  54. "show_work_period": "1",
  55. "show_triggers": "0",
  56. "graphtype": "1",
  57. "show_legend": "1",
  58. "show_3d": "0",
  59. "percent_left": "0.0000",
  60. "percent_right": "0.0000",
  61. "ymin_type": "1",
  62. "ymax_type": "1",
  63. "ymin_itemid": "0",
  64. "ymax_itemid": "0",
  65. "flags": "0"
  66. },
  67. {
  68. "graphid": "645",
  69. "name": "Disk space usage /",
  70. "width": "600",
  71. "height": "340",
  72. "yaxismin": "0.0000",
  73. "yaxismax": "0.0000",
  74. "templateid": "0",
  75. "show_work_period": "0",
  76. "show_triggers": "0",
  77. "graphtype": "2",
  78. "show_legend": "1",
  79. "show_3d": "1",
  80. "percent_left": "0.0000",
  81. "percent_right": "0.0000",
  82. "ymin_type": "0",
  83. "ymax_type": "0",
  84. "ymin_itemid": "0",
  85. "ymax_itemid": "0",
  86. "flags": "4"
  87. }
  88. ],
  89. "id": 1
  90. }

See also

Source

CGraph::get() in ui/include/classes/api/services/CGraph.php.