• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript elastic-idx.idx函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@kbn/elastic-idx.idx函数的典型用法代码示例。如果您正苦于以下问题:TypeScript idx函数的具体用法?TypeScript idx怎么用?TypeScript idx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: getService

export async function getService(serviceName: string, setup: Setup) {
  const { start, end, uiFiltersES, client, config } = setup;

  const params = {
    index: [
      config.get<string>('apm_oss.errorIndices'),
      config.get<string>('apm_oss.transactionIndices')
    ],
    body: {
      size: 0,
      query: {
        bool: {
          filter: [
            { term: { [SERVICE_NAME]: serviceName } },
            { terms: { [PROCESSOR_EVENT]: ['error', 'transaction'] } },
            { range: rangeFilter(start, end) },
            ...uiFiltersES
          ]
        }
      },
      aggs: {
        types: {
          terms: { field: TRANSACTION_TYPE, size: 100 }
        },
        agents: {
          terms: { field: SERVICE_AGENT_NAME, size: 1 }
        }
      }
    }
  };

  interface Aggs {
    types: {
      buckets: BucketAgg[];
    };
    agents: {
      buckets: BucketAgg[];
    };
  }

  const { aggregations } = await client<void, Aggs>('search', params);
  const buckets = idx(aggregations, _ => _.types.buckets) || [];
  const types = buckets.map(bucket => bucket.key);
  const agentName = idx(aggregations, _ => _.agents.buckets[0].key) || '';
  return {
    serviceName,
    types,
    agentName
  };
}
开发者ID:elastic,项目名称:kibana,代码行数:50,代码来源:get_service.ts


示例2: getErrorGroup

export async function getErrorGroup({
  serviceName,
  groupId,
  setup
}: {
  serviceName: string;
  groupId: string;
  setup: Setup;
}) {
  const { start, end, uiFiltersES, client, config } = setup;

  const params = {
    index: config.get<string>('apm_oss.errorIndices'),
    body: {
      size: 1,
      query: {
        bool: {
          filter: [
            { term: { [SERVICE_NAME]: serviceName } },
            { term: { [PROCESSOR_EVENT]: 'error' } },
            { term: { [ERROR_GROUP_ID]: groupId } },
            { range: rangeFilter(start, end) },
            ...uiFiltersES
          ],
          should: [{ term: { [TRANSACTION_SAMPLED]: true } }]
        }
      },
      sort: [
        { _score: 'desc' }, // sort by _score first to ensure that errors with transaction.sampled:true ends up on top
        { '@timestamp': { order: 'desc' } } // sort by timestamp to get the most recent error
      ]
    }
  };

  const resp = await client<APMError>('search', params);
  const error = idx(resp, _ => _.hits.hits[0]._source);
  const transactionId = idx(error, _ => _.transaction.id);
  const traceId = idx(error, _ => _.trace.id);

  let transaction;
  if (transactionId && traceId) {
    transaction = await getTransaction(transactionId, traceId, setup);
  }

  return {
    transaction,
    error,
    occurrencesCount: resp.hits.total
  };
}
开发者ID:elastic,项目名称:kibana,代码行数:50,代码来源:get_error_group.ts


示例3: idx

  const hits = buckets.map(bucket => {
    const source = bucket.sample.hits.hits[0]._source;
    const message =
      idx(source, _ => _.error.log.message) ||
      idx(source, _ => _.error.exception[0].message);

    return {
      message,
      occurrenceCount: bucket.doc_count,
      culprit: idx(source, _ => _.error.culprit),
      groupId: idx(source, _ => _.error.grouping_key),
      latestOccurrenceAt: source['@timestamp'],
      handled: idx(source, _ => _.error.exception[0].handled)
    };
  });
开发者ID:elastic,项目名称:kibana,代码行数:15,代码来源:get_error_groups.ts


示例4: getTransaction

export async function getTransaction(
  transactionId: string,
  traceId: string,
  setup: Setup
) {
  const { start, end, uiFiltersES, client, config } = setup;

  const params = {
    index: config.get<string>('apm_oss.transactionIndices'),
    body: {
      size: 1,
      query: {
        bool: {
          filter: [
            { term: { [PROCESSOR_EVENT]: 'transaction' } },
            { term: { [TRANSACTION_ID]: transactionId } },
            { term: { [TRACE_ID]: traceId } },
            { range: rangeFilter(start, end) },
            ...uiFiltersES
          ]
        }
      }
    }
  };

  const resp = await client<Transaction>('search', params);
  return idx(resp, _ => _.hits.hits[0]._source);
}
开发者ID:elastic,项目名称:kibana,代码行数:28,代码来源:index.ts


示例5: getBucket

function getBucket(
  bucket: ESResponse['aggregations']['distribution']['buckets'][0]
) {
  const sampleSource = idx(bucket, _ => _.sample.hits.hits[0]._source);
  const isSampled = idx(sampleSource, _ => _.transaction.sampled);
  const sample = {
    traceId: idx(sampleSource, _ => _.trace.id),
    transactionId: idx(sampleSource, _ => _.transaction.id)
  };

  return {
    key: bucket.key,
    count: bucket.doc_count,
    sample: isSampled ? sample : undefined
  };
}
开发者ID:elastic,项目名称:kibana,代码行数:16,代码来源:transform.ts


示例6: anomalySeriesTransform

export function anomalySeriesTransform(
  response: ESResponse,
  mlBucketSize: number,
  bucketSize: number,
  timeSeriesDates: number[]
) {
  if (!response) {
    return;
  }

  const buckets = (
    idx(response, _ => _.aggregations.ml_avg_response_times.buckets) || []
  ).map(getBucket);

  const bucketSizeInMillis = Math.max(bucketSize, mlBucketSize) * 1000;

  return {
    anomalyScore: getAnomalyScoreDataPoints(
      buckets,
      timeSeriesDates,
      bucketSizeInMillis
    ),
    anomalyBoundaries: getAnomalyBoundaryDataPoints(buckets, timeSeriesDates)
  };
}
开发者ID:elastic,项目名称:kibana,代码行数:25,代码来源:transform.ts


示例7: return

  return (id?: IWaterfallItem['id']) => {
    if (!id) {
      return undefined;
    }

    const item = itemsById[id];
    if (idx(item, _ => _.docType) === 'transaction') {
      return (item as IWaterfallItemTransaction).transaction;
    }
  };
开发者ID:elastic,项目名称:kibana,代码行数:10,代码来源:waterfall_helpers.ts


示例8: getEnvironments

export async function getEnvironments(setup: Setup, serviceName?: string) {
  const { start, end, client, config } = setup;

  const filter: ESFilter[] = [
    { terms: { [PROCESSOR_EVENT]: ['transaction', 'error', 'metric'] } },
    { range: rangeFilter(start, end) }
  ];

  if (serviceName) {
    filter.push({
      term: { [SERVICE_NAME]: serviceName }
    });
  }

  const params = {
    index: [
      config.get<string>('apm_oss.metricsIndices'),
      config.get<string>('apm_oss.errorIndices'),
      config.get<string>('apm_oss.transactionIndices')
    ],
    body: {
      size: 0,
      query: {
        bool: {
          filter
        }
      },
      aggs: {
        environments: {
          terms: {
            field: SERVICE_ENVIRONMENT,
            missing: ENVIRONMENT_NOT_DEFINED
          }
        }
      }
    }
  };

  interface Aggs extends BucketAgg {
    environments: {
      buckets: BucketAgg[];
    };
  }

  const resp = await client<void, Aggs>('search', params);
  const aggs = resp.aggregations;
  const environmentsBuckets = idx(aggs, _ => _.environments.buckets) || [];

  const environments = environmentsBuckets.map(
    environmentBucket => environmentBucket.key
  );

  return environments;
}
开发者ID:elastic,项目名称:kibana,代码行数:54,代码来源:get_environments.ts


示例9: transactionGroupsTransformer

export function transactionGroupsTransformer({
  response,
  start,
  end
}: {
  response: ESResponse;
  start: number;
  end: number;
}): ITransactionGroup[] {
  const buckets = idx(response, _ => _.aggregations.transactions.buckets) || [];
  const duration = moment.duration(end - start);
  const minutes = duration.asMinutes();
  const transactionGroups = buckets.map(bucket =>
    getTransactionGroup(bucket, minutes)
  );

  return calculateRelativeImpacts(transactionGroups);
}
开发者ID:elastic,项目名称:kibana,代码行数:18,代码来源:transform.ts


示例10: getMlBucketSize

export async function getMlBucketSize({
  serviceName,
  transactionType,
  setup
}: IOptions): Promise<number> {
  const { client, start, end } = setup;
  const params = {
    index: getMlIndex(serviceName, transactionType),
    body: {
      _source: 'bucket_span',
      size: 1,
      query: {
        bool: {
          filter: [
            { exists: { field: 'bucket_span' } },
            {
              range: {
                timestamp: {
                  gte: start,
                  lte: end,
                  format: 'epoch_millis'
                }
              }
            }
          ]
        }
      }
    }
  };

  try {
    const resp = await client<ESResponse>('search', params);
    return idx(resp, _ => _.hits.hits[0]._source.bucket_span) || 0;
  } catch (err) {
    const isHttpError = 'statusCode' in err;
    if (isHttpError) {
      return 0;
    }
    throw err;
  }
}
开发者ID:elastic,项目名称:kibana,代码行数:41,代码来源:get_ml_bucket_size.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript es-query.fromKueryExpression函数代码示例发布时间:2022-05-28
下一篇:
TypeScript dev-utils.ToolingLog类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap