Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary operation of Transform can not work when use compareQueries #41

Open
realjustinwu opened this issue Dec 13, 2023 · 0 comments
Open

Comments

@realjustinwu
Copy link

realjustinwu commented Dec 13, 2023

DataSource Type: ElasticSearch
Grafana Version: v10.1.5

image image image

The above configuration can show the values of A-B, but when querying for C or D with hide disabled, A-B can no longer be displayed.

Note: Binary operation with one Query, the operation works well. (e.g. A - 100)

Following is the panel JSON.

{
  "datasource": {
    "uid": "jeBmg5Hnz",
    "type": "autohome-comparequeries-datasource"
  },
  "fieldConfig": {
    "defaults": {
      "custom": {
        "drawStyle": "line",
        "lineInterpolation": "linear",
        "barAlignment": 0,
        "lineWidth": 1,
        "fillOpacity": 0,
        "gradientMode": "none",
        "spanNulls": false,
        "insertNulls": false,
        "showPoints": "auto",
        "pointSize": 5,
        "stacking": {
          "mode": "none",
          "group": "A"
        },
        "axisPlacement": "auto",
        "axisLabel": "",
        "axisColorMode": "text",
        "scaleDistribution": {
          "type": "linear"
        },
        "axisCenteredZero": false,
        "hideFrom": {
          "tooltip": false,
          "viz": false,
          "legend": false
        },
        "thresholdsStyle": {
          "mode": "off"
        }
      },
      "color": {
        "mode": "palette-classic"
      },
      "mappings": [],
      "thresholds": {
        "mode": "absolute",
        "steps": [
          {
            "value": null,
            "color": "green"
          },
          {
            "value": 80,
            "color": "red"
          }
        ]
      },
      "unit": "percentunit"
    },
    "overrides": []
  },
  "gridPos": {
    "h": 8,
    "w": 4.9,
    "x": 0,
    "y": 11.5
  },
  "id": 7,
  "interval": "${Interval}",
  "targets": [
    {
      "datasource": {
        "uid": "f8qfVL7Vz",
        "type": "elasticsearch"
      },
      "alias": "A",
      "bucketAggs": [
        {
          "type": "date_histogram",
          "id": "2",
          "settings": {
            "interval": "auto"
          },
          "field": "@timestamp"
        }
      ],
      "metrics": [
        {
          "id": "1",
          "type": "count"
        }
      ],
      "query": "name: \"app.anr\"",
      "timeField": "@timestamp",
      "refId": "A",
      "hide": false
    },
    {
      "datasource": {
        "uid": "f8qfVL7Vz",
        "type": "elasticsearch"
      },
      "alias": "B",
      "bucketAggs": [
        {
          "id": "2",
          "settings": {
            "interval": "auto"
          },
          "type": "date_histogram"
        }
      ],
      "metrics": [
        {
          "field": "user",
          "id": "1",
          "settings": {},
          "type": "cardinality"
        }
      ],
      "query": "name: \"app.tick\"",
      "timeField": "@timestamp",
      "refId": "B",
      "hide": false
    },
    {
      "datasource": {
        "type": "autohome-comparequeries-datasource",
        "uid": "jeBmg5Hnz"
      },
      "refId": "C",
      "hide": true,
      "timeShifts": [
        {
          "id": 0,
          "$$hashKey": "object:242",
          "aliasType": "suffix",
          "value": "7d",
          "alias": null,
          "delimiter": "_"
        }
      ],
      "process": true,
      "query": "A"
    },
    {
      "datasource": {
        "type": "autohome-comparequeries-datasource",
        "uid": "jeBmg5Hnz"
      },
      "refId": "D",
      "hide": true,
      "timeShifts": [
        {
          "id": 0,
          "$$hashKey": "object:254",
          "aliasType": "suffix",
          "value": "7d",
          "alias": null,
          "delimiter": "_"
        }
      ],
      "process": true,
      "query": "B"
    }
  ],
  "title": "Free Users Trend",
  "transformations": [
    {
      "id": "calculateField",
      "options": {
        "mode": "binary",
        "reduce": {
          "reducer": "sum"
        },
        "binary": {
          "left": "A",
          "reducer": "sum",
          "operator": "-",
          "right": "B"
        },
        "alias": "A Value_8d0",
        "replaceFields": false
      }
    }
  ],
  "type": "timeseries",
  "options": {
    "tooltip": {
      "mode": "single",
      "sort": "none"
    },
    "legend": {
      "showLegend": true,
      "displayMode": "list",
      "placement": "bottom",
      "calcs": []
    }
  },
  "pluginVersion": "10.1.5",
  "timeFrom": null,
  "timeShift": null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant