當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。