当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript TemplateSrv.replace方法代码示例

本文整理汇总了TypeScript中app/features/templating/template_srv.TemplateSrv.replace方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TemplateSrv.replace方法的具体用法?TypeScript TemplateSrv.replace怎么用?TypeScript TemplateSrv.replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app/features/templating/template_srv.TemplateSrv的用法示例。


在下文中一共展示了TemplateSrv.replace方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: LogAnalyticsQuerystringBuilder

    }).map(target => {
      const item = target.azureLogAnalytics;

      const querystringBuilder = new LogAnalyticsQuerystringBuilder(
        this.templateSrv.replace(item.query, options.scopedVars, this.interpolateVariable),
        options,
        'TimeGenerated'
      );
      const generated = querystringBuilder.generate();

      const workspace = this.templateSrv.replace(item.workspace, options.scopedVars);

      const url = `${this.baseUrl}/${workspace}/query?${generated.uriString}`;

      return {
        refId: target.refId,
        intervalMs: options.intervalMs,
        maxDataPoints: options.maxDataPoints,
        datasourceId: this.id,
        url: url,
        query: generated.rawQuery,
        format: target.format,
        resultFormat: item.resultFormat,
      };
    });
开发者ID:grafana,项目名称:grafana,代码行数:25,代码来源:azure_log_analytics_datasource.ts

示例2: getResourceARNs

 getResourceARNs(region, resourceType, tags) {
   return this.doMetricQueryRequest('resource_arns', {
     region: this.templateSrv.replace(this.getActualRegion(region)),
     resourceType: this.templateSrv.replace(resourceType),
     tags: tags,
   });
 }
开发者ID:johntdyer,项目名称:grafana,代码行数:7,代码来源:datasource.ts

示例3: getEc2InstanceAttribute

 getEc2InstanceAttribute(region, attributeName, filters) {
   return this.doMetricQueryRequest('ec2_instance_attribute', {
     region: this.templateSrv.replace(this.getActualRegion(region)),
     attributeName: this.templateSrv.replace(attributeName),
     filters: filters,
   });
 }
开发者ID:johntdyer,项目名称:grafana,代码行数:7,代码来源:datasource.ts

示例4: getDimensionValues

 getDimensionValues(region, namespace, metricName, dimensionKey, filterDimensions) {
   return this.doMetricQueryRequest('dimension_values', {
     region: this.templateSrv.replace(this.getActualRegion(region)),
     namespace: this.templateSrv.replace(namespace),
     metricName: this.templateSrv.replace(metricName),
     dimensionKey: this.templateSrv.replace(dimensionKey),
     dimensions: this.convertDimensionFormat(filterDimensions, {}),
   });
 }
开发者ID:johntdyer,项目名称:grafana,代码行数:9,代码来源:datasource.ts

示例5:

 .map(t => {
   return {
     refId: t.refId,
     intervalMs: options.intervalMs,
     datasourceId: this.id,
     metricType: this.templateSrv.replace(t.metricType, options.scopedVars || {}),
     crossSeriesReducer: this.templateSrv.replace(t.crossSeriesReducer || 'REDUCE_MEAN', options.scopedVars || {}),
     perSeriesAligner: this.templateSrv.replace(t.perSeriesAligner, options.scopedVars || {}),
     alignmentPeriod: this.templateSrv.replace(t.alignmentPeriod, options.scopedVars || {}),
     groupBys: this.interpolateGroupBys(t.groupBys, options.scopedVars),
     view: t.view || 'FULL',
     filters: this.interpolateFilters(t.filters, options.scopedVars),
     aliasBy: this.templateSrv.replace(t.aliasBy, options.scopedVars || {}),
     type: 'timeSeriesQuery',
   };
 });
开发者ID:grafana,项目名称:grafana,代码行数:16,代码来源:datasource.ts

示例6: annotationQuery

  annotationQuery(options) {
    const annotation = options.annotation;
    const statistics = _.map(annotation.statistics, s => {
      return this.templateSrv.replace(s);
    });
    const defaultPeriod = annotation.prefixMatching ? '' : '300';
    let period = annotation.period || defaultPeriod;
    period = parseInt(period, 10);
    const parameters = {
      prefixMatching: annotation.prefixMatching,
      region: this.templateSrv.replace(this.getActualRegion(annotation.region)),
      namespace: this.templateSrv.replace(annotation.namespace),
      metricName: this.templateSrv.replace(annotation.metricName),
      dimensions: this.convertDimensionFormat(annotation.dimensions, {}),
      statistics: statistics,
      period: period,
      actionPrefix: annotation.actionPrefix || '',
      alarmNamePrefix: annotation.alarmNamePrefix || '',
    };

    return this.awsRequest('/api/tsdb/query', {
      from: options.range.from.valueOf().toString(),
      to: options.range.to.valueOf().toString(),
      queries: [
        _.extend(
          {
            refId: 'annotationQuery',
            intervalMs: 1, // dummy
            maxDataPoints: 1, // dummy
            datasourceId: this.instanceSettings.id,
            type: 'annotationQuery',
          },
          parameters
        ),
      ],
    }).then(r => {
      return _.map(r.results['annotationQuery'].tables[0].rows, v => {
        return {
          annotation: annotation,
          time: Date.parse(v[0]),
          title: v[1],
          tags: [v[2]],
          text: v[3],
        };
      });
    });
  }
开发者ID:johntdyer,项目名称:grafana,代码行数:47,代码来源:datasource.ts

示例7: annotationQuery

  async annotationQuery(options) {
    const annotation = options.annotation;
    const queries = [
      {
        refId: 'annotationQuery',
        datasourceId: this.id,
        metricType: this.templateSrv.replace(annotation.target.metricType, options.scopedVars || {}),
        crossSeriesReducer: 'REDUCE_NONE',
        perSeriesAligner: 'ALIGN_NONE',
        title: this.templateSrv.replace(annotation.target.title, options.scopedVars || {}),
        text: this.templateSrv.replace(annotation.target.text, options.scopedVars || {}),
        tags: this.templateSrv.replace(annotation.target.tags, options.scopedVars || {}),
        view: 'FULL',
        filters: (annotation.target.filters || []).map(f => {
          return this.templateSrv.replace(f, options.scopedVars || {});
        }),
        type: 'annotationQuery',
      },
    ];

    const { data } = await this.backendSrv.datasourceRequest({
      url: '/api/tsdb/query',
      method: 'POST',
      data: {
        from: options.range.from.valueOf().toString(),
        to: options.range.to.valueOf().toString(),
        queries,
      },
    });

    const results = data.results['annotationQuery'].tables[0].rows.map(v => {
      return {
        annotation: annotation,
        time: Date.parse(v[0]),
        title: v[1],
        tags: [],
        text: v[3],
      };
    });

    return results;
  }
开发者ID:grafana,项目名称:grafana,代码行数:42,代码来源:datasource.ts

示例8: prepareQueryTarget

 prepareQueryTarget(target, options) {
   const interpolated = this.templateSrv.replace(target.expr);
   const start = this.getTime(options.range.from, false);
   const end = this.getTime(options.range.to, true);
   return {
     ...DEFAULT_QUERY_PARAMS,
     ...parseQuery(interpolated),
     start,
     end,
     limit: this.maxLines,
   };
 }
开发者ID:johntdyer,项目名称:grafana,代码行数:12,代码来源:datasource.ts

示例9: String

    }).map(item => {
      item.region = this.templateSrv.replace(this.getActualRegion(item.region), options.scopedVars);
      item.namespace = this.templateSrv.replace(item.namespace, options.scopedVars);
      item.metricName = this.templateSrv.replace(item.metricName, options.scopedVars);
      item.dimensions = this.convertDimensionFormat(item.dimensions, options.scopedVars);
      item.statistics = item.statistics.map(s => {
        return this.templateSrv.replace(s, options.scopedVars);
      });
      item.period = String(this.getPeriod(item, options)); // use string format for period in graph query, and alerting
      item.id = this.templateSrv.replace(item.id, options.scopedVars);
      item.expression = this.templateSrv.replace(item.expression, options.scopedVars);
      item.returnData = typeof item.hide === 'undefined' ? true : !item.hide;

      // valid ExtendedStatistics is like p90.00, check the pattern
      const hasInvalidStatistics = item.statistics.some(s => {
        if (s.indexOf('p') === 0) {
          const matches = /^p\d{2}(?:\.\d{1,2})?$/.exec(s);
          return !matches || matches[0] !== s;
        }

        return false;
      });

      if (hasInvalidStatistics) {
        throw { message: 'Invalid extended statistics' };
      }

      return _.extend(
        {
          refId: item.refId,
          intervalMs: options.intervalMs,
          maxDataPoints: options.maxDataPoints,
          datasourceId: this.instanceSettings.id,
          type: 'timeSeriesQuery',
        },
        item
      );
    });
开发者ID:johntdyer,项目名称:grafana,代码行数:38,代码来源:datasource.ts


注:本文中的app/features/templating/template_srv.TemplateSrv.replace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。