Uploaded image for project: 'ZABBIX FEATURE REQUESTS'
  1. ZABBIX FEATURE REQUESTS
  2. ZBXNEXT-3974

API "trend.get" call doesn't support sorting

XMLWordPrintable

    • Icon: Change Request Change Request
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 3.2.6
    • API (A), Frontend (F)
    • None

      Documentation says

      The following parameters are supported by all get methods:

      • ...
      • sortfield
      • sortorder
      • ...

      But using "sortfield" and/or "sortorder" in "trend.get" call has no effect:

      Example 1. Sorting by clock doesn't work
      Request:
      {
        "auth": "...",
        "id": 1,
        "params": {
          "time_till": 1498710000,
          "time_from": 1498700000,
          "sortorder": "ASC",
          "sortfield": "clock",
          "itemids": [
            "26031",
            "26032"
          ],
          "trend": "0",
          "output": [
            "itemid",
            "clock"
          ]
        },
        "method": "trend.get",
        "jsonrpc": "2.0"
      }
      
      Response:
      {
        "id": 1,
        "result": [
          {
            "clock": "1498701600",
            "itemid": "26031"
          },
          {
            "clock": "1498705200",
            "itemid": "26031"
          },
          {
            "clock": "1498708800",
            "itemid": "26031"
          },
          {
            "clock": "1498701600",
            "itemid": "26032"
          },
          {
            "clock": "1498705200",
            "itemid": "26032"
          },
          {
            "clock": "1498708800",
            "itemid": "26032"
          }
        ],
        "jsonrpc": "2.0"
      }
      
      Example 2. Descending sorting by itemid doesnt' work
      Request:
      {
        "auth": "...",
        "id": 1,
        "params": {
          "time_till": 1498710000,
          "time_from": 1498700000,
          "sortorder": "DESC",
          "sortfield": "itemid",
          "itemids": [
            "26031",
            "26032"
          ],
          "trend": "0",
          "output": [
            "itemid",
            "clock"
          ]
        },
        "method": "trend.get",
        "jsonrpc": "2.0"
      }
      
      Response:
      {
        "id": 1,
        "result": [
          {
            "clock": "1498701600",
            "itemid": "26031"
          },
          {
            "clock": "1498705200",
            "itemid": "26031"
          },
          {
            "clock": "1498708800",
            "itemid": "26031"
          },
          {
            "clock": "1498701600",
            "itemid": "26032"
          },
          {
            "clock": "1498705200",
            "itemid": "26032"
          },
          {
            "clock": "1498708800",
            "itemid": "26032"
          }
        ],
        "jsonrpc": "2.0"
      }
      

      applyQuerySortOptions isn't used in include/classes/api/services/CTrend.php. Neither does ORDER BY SQL clause.

            Unassigned Unassigned
            akint Anton Alekseev
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: