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

TimeSeries min, max #474

Open
baryluk opened this issue Mar 15, 2022 · 1 comment
Open

TimeSeries min, max #474

baryluk opened this issue Mar 15, 2022 · 1 comment

Comments

@baryluk
Copy link

baryluk commented Mar 15, 2022

We are migrating about 40 dashboards from Graph to TimeSeries, and created wrapper that converts things, like this:

def G(*args, **kwargs):
    if OLD_GRAFANA:
        return Graph(*args, **kwargs)
    if "stack" in kwargs:
        if kwargs.pop("stack"):
            kwargs["stacking"] = {"mode": "normal"}
    if "yAxes" in kwargs:
        yAxes = kwargs.pop("yAxes")

        if yAxes.left.label is not None:
            kwargs["axisLabel"] = yAxes.left.label

        if yAxes.left.min is not None:
            pass # ???
        if yAxes.left.max is not None:
            pass # ???

        if yAxes.left.format:
            kwargs["unit"] = yAxes.left.format
        if yAxes.left.logBase and yAxes.left.logBase != 1:
            kwargs["scaleDistributionType"] = "log"
            kwargs["scaleDistributionLog"] = yAxes.left.logBase
    return TimeSeries(*args, **kwargs)

But i noticed that TimeSeries does not provide min, max, softMin and softMax.

If in Grafana UI, I click "Migrate", I got these fieldConfig:

      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisLabel": "Latency",
            "axisPlacement": "auto",
            "axisSoftMin": 0,
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "stepAfter",
            "lineWidth": 2,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "links": [],
          "mappings": [],
          "max": 1e-7,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "s"
        },
        "overrides": []
      },

So I see there are options for these things.

@baryluk
Copy link
Author

baryluk commented Mar 15, 2022

As a workaround:

...
        if yAxes.left.min is not None:
            kwargs.setdefault("extraJson", {}).setdefault("fieldConfig", {}).setdefault("defaults", {})["min"] = yAxes.left.min

        if yAxes.left.max is not None:
            kwargs.setdefault("extraJson", {}).setdefault("fieldConfig", {}).setdefault("defaults", {})["max"] = yAxes.left.max

...

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