小编and*_*oga的帖子

普罗米修斯“负”偏移量

我正在尝试使用普罗米修斯数据源在 Grafana 中绘制条形图。我的简单查询如下所示:

max_over_time(energy_monitor_watthour_today[1d])

我将 Grafana 设置为 1d 的间隔(这很好用,并为我提供了每天的最高点)。但是使用这个,我所有的结果都在未来的 1 天之内。我想基本上给我的结果一个偏移量,将它们推到过去 1 天。

我曾尝试使用 Prometheus 的 Offset 函数进行查询: max_over_time(energy_monitor_watthour_today[1d] offset 1d)

但这会产生完全相反的效果,并将我的所有结果都移到未来 1 天。使用像这样的负偏移量:

max_over_time(energy_monitor_watthour_today[1d] offset -1d)

导致以下错误:

字符 57 处的解析错误:偏移量意外,预期持续时间

我也尝试使用 Grafana 的时间偏移功能,但这只会移动我的图表的时间范围,而不是更改实际日期。

如何将我查询的所有结果移动到过去某一天?

prometheus promql

5
推荐指数
1
解决办法
1959
查看次数

Angular Schematics - 将库添加到 NgModule 导入中

当使用 Schematics 在 Angular 中生成组件时,它会尝试将新生成的组件导入到 NgModule 中,这是为了组件正常工作并节省时间所必需的。

但是,在创建自己的原理图时,我无法找到正确的方法来执行相同的操作并将我的库导入到 app.component.ts 的 NgModule 中。使用 ng-add 原理图时,如何让原理图自动将自己的条目添加到 NgModule 中?

原理图需要做两件事:

  1. 导入库
  2. 将其添加到 NgModule 导入中

前:

@NgModule({
  declarations: [],
  imports: [],
  exports: []
})
export class appModule { }
Run Code Online (Sandbox Code Playgroud)

后:

import {library} from 'library';

@NgModule({
  declarations: [],
  imports: [library],
  exports: []
})
export class appModule { }
Run Code Online (Sandbox Code Playgroud)

我知道 Angular devkit 中存在执行此操作的函数,因为组件等的“官方”原理图使用了它。我会怎样做同样的事情?

typescript angular angular-schematics

2
推荐指数
1
解决办法
2404
查看次数