菜单
Grafana Cloud Enterprise 开源

时间设置

`TimeSettingsSpec` 定义了特定仪表盘的时间选择器和刷新选择器的默认时间配置。

以下是默认时间设置的 JSON 结构

json
  "timeSettings": {
    "autoRefresh": "",
    "autoRefreshIntervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "fiscalYearStartMonth": 0,
    "from": "now-6h",
    "hideTimepicker": false,
    "timezone": "browser",
    "to": "now"
  },

`timeSettings` 包括

TimeSettingsSpec

下表解释了时间设置 JSON 字段的用法

名称用法
timezone?字符串。仪表盘的时区。接受的值为 IANA TZDB 区域 ID、`browser`(浏览器时区)或 `utc`。默认值为 `browser`。
from字符串。仪表盘的开始时间范围。接受的值为相对时间字符串,例如 `now-6h`,或绝对时间字符串,例如 `2020-07-10T08:00:00.000Z`。默认值为 `now-6h`。
to字符串。仪表盘的结束时间范围。接受的值为相对时间字符串,例如 `now-6h`,或绝对时间字符串,例如 `2020-07-10T08:00:00.000Z`。默认值为 `now`。
autoRefresh字符串。仪表盘的刷新频率。以间隔字符串表示。例如:`5s`、`1m`、`1h`、`1d`。没有默认值。在 schema v1 中为 `refresh`。
autoRefreshIntervals字符串。刷新选择器下拉菜单中可用的间隔选项。默认数组为 `["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"]`。
quickRanges?时间选择器下拉菜单中可选择的选项。对已配置的仪表盘无效。在 TimeRangeOption 规范中定义。在 schema v1 中为 timepicker.quick_ranges,未在 UI 中公开。
hideTimepicker布尔值。时间选择器是否可见。默认值为 `false`。在 schema v1 中为 `timepicker.hidden`。
weekStart?一周开始的日期。以小写日期名称表示。例如:monday。选项为 saturdaymondaysunday
fiscalYearStartMonth财政年度开始的月份。0 = 一月,11 = 十二月
nowDelay?字符串。通过输入时间延迟来覆盖“现在”时间。使用此选项来适应已知的数据聚合延迟,以避免出现空值。在 schema v1 中为 `timepicker.nowDelay`。

TimeRangeOption

下表解释了时间范围选项 JSON 字段的用法

名称用法
display字符串。默认值为 Last 6 hours
from字符串。默认值为 now-6h
to字符串。默认值为 now