types#Metric TypeScript Examples

The following examples show how to use types#Metric. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: getResultQuery.tsx    From grafana-weathermap-panel with Apache License 2.0 6 votes vote down vote up
searchNameIsFilter = (query: DataFrame, mainMetric: Metric): boolean => {
  if (!mainMetric.filter) {
    return true;
  }
  let res = 0;
  const filters: Filtred[] = mainMetric.filter;
  let remove = query.name?.split('{');
  const nameQuery: string[] =
    remove![1].split(',').map((value) => {
      return value.replace(/[\"{}]/gm, '');
    }) || [];
  if (nameQuery && nameQuery.length > 0) {
    for (const oneQuery of nameQuery) {
      const keyValue: string[] = oneQuery.split('=');
      for (const filter of filters) {
        if (keyValue.length === 2) {
          if (keyValue[0] === filter.label && keyValue[1] === filter.value) {
            res++;
          }
        }
      }
    }
    // console.log(res);
    // console.log(filters.length)
    if (res === filters.length) {
      return true;
    }
  }
  return false;
}
Example #2
Source File: manageQuery.tsx    From grafana-weathermap-panel with Apache License 2.0 6 votes vote down vote up
private getDefaultManageValueB = (): SelectableValue<TManageValue> => {
    let defaultValue: SelectableValue<TManageValue> = { label: 'avg', value: 'avg' };
    const mainMetricB: Metric = this.state.mainMetricB;
    for (const value of this.state.selectManageValue) {
      if (mainMetricB.manageValue) {
        if (mainMetricB.manageValue === value.value) {
          defaultValue = value;
        }
      }
    }
    return defaultValue;
  };
Example #3
Source File: manageQuery.tsx    From grafana-weathermap-panel with Apache License 2.0 6 votes vote down vote up
private getDefaultManageValue = (): SelectableValue<TManageValue> => {
    let defaultValue: SelectableValue<TManageValue> = { label: 'avg', value: 'avg' };
    const mainMetric: Metric = this.state.mainMetric;
    for (const value of this.state.selectManageValue) {
      if (mainMetric.manageValue) {
        if (mainMetric.manageValue === value.value) {
          defaultValue = value;
        }
      }
    }
    return defaultValue;
  };
Example #4
Source File: manageQuery.tsx    From grafana-weathermap-panel with Apache License 2.0 6 votes vote down vote up
private getDefaultQueryB = (): SelectableValue<DataFrame> => {
    let defaultValue: SelectableValue<DataFrame> = { label: 'No value', value: undefined };
    const mainMetricB: Metric = this.state.mainMetricB;
    for (const value of this.state.selectQuery) {
      if (mainMetricB.refId) {
        if (mainMetricB.refId === value.label) {
          defaultValue = value;
        }
      }
    }
    return defaultValue;
  };
Example #5
Source File: manageQuery.tsx    From grafana-weathermap-panel with Apache License 2.0 6 votes vote down vote up
/** edit value for select */
  onChangeSelectQueryB = (value: SelectableValue<DataFrame>) => {
    const newMainMetric: Metric = this.state.mainMetricB;
    newMainMetric.refId = value.value?.refId || '';
    newMainMetric.expr = '';
    this.setState({
      mainMetricB: newMainMetric,
    });
    this.callBackB();
  };
Example #6
Source File: manageQuery.tsx    From grafana-weathermap-panel with Apache License 2.0 6 votes vote down vote up
/** edit value for select */
  onChangeSelectQuery = (value: SelectableValue<DataFrame>) => {
    const newMainMetric: Metric = this.state.mainMetric;
    newMainMetric.refId = value.value?.refId || '';
    newMainMetric.expr = '';
    this.setState({
      mainMetric: newMainMetric,
      selectQueryDefault: value,
    });
    this.callBack();
  };
Example #7
Source File: manageQuery.tsx    From grafana-weathermap-panel with Apache License 2.0 6 votes vote down vote up
/** edit value keyValue for mainMetric */
  _handleChangeKeyValueB = (value: string) => {
    const newMainMetric: Metric = this.state.mainMetricB;
    newMainMetric.keyValue = value;
    this.setState({
      mainMetricB: newMainMetric,
    });
    this.callBackB();
  };
Example #8
Source File: manageQuery.tsx    From grafana-weathermap-panel with Apache License 2.0 6 votes vote down vote up
/** edit value keyValue for mainMetric */
  _handleChangeKeyValue = (value: string) => {
    const newMainMetric: Metric = this.state.mainMetric;
    newMainMetric.keyValue = value;
    this.setState({
      mainMetric: newMainMetric,
    });
    this.callBack();
  };
Example #9
Source File: manageQuery.tsx    From grafana-weathermap-panel with Apache License 2.0 6 votes vote down vote up
/** edit value key for mainMetric */
  _handleChangeKeyB = (value: string) => {
    const newMainMetric: Metric = this.state.mainMetricB;
    newMainMetric.key = value;
    this.setState({
      mainMetricB: newMainMetric,
    });
    this.callBackB();
  };
Example #10
Source File: manageQuery.tsx    From grafana-weathermap-panel with Apache License 2.0 6 votes vote down vote up
/** edit value key for mainMetric */
  _handleChangeKey = (value: string) => {
    const newMainMetric: Metric = this.state.mainMetric;
    newMainMetric.key = value;
    this.setState({
      mainMetric: newMainMetric,
    });
    this.callBack();
  };
Example #11
Source File: manageQuery.tsx    From grafana-weathermap-panel with Apache License 2.0 6 votes vote down vote up
/** edit value for default select manage value */
  onChangeSelectManageValueB = (value: SelectableValue<TManageValue>) => {
    const newMainMetric: Metric = this.state.mainMetricB;
    //const arrayOrientedLinks: OrientedLink = this.props.options.arrayOrientedLinks
    newMainMetric.manageValue = value.value || 'err';
    this.setState({
      mainMetricB: newMainMetric,
    });
    this.callBackB();
  };
Example #12
Source File: manageQuery.tsx    From grafana-weathermap-panel with Apache License 2.0 6 votes vote down vote up
/** edit value for default select manage value */
  onChangeSelectManageValue = (value: SelectableValue<TManageValue>) => {
    const newMainMetric: Metric = this.state.mainMetric;
    newMainMetric.manageValue = value.value || 'err';
    this.setState({
      mainMetric: newMainMetric,
      //selectDefaultManageValue: value,
    });
    this.callBack();
  };
Example #13
Source File: coordinateSpace.tsx    From grafana-weathermap-panel with Apache License 2.0 6 votes vote down vote up
/** save mainMetric data */
  callBackMainMetric = (mainMetric: Metric): void => {
    const newValue: RegionClass = this.state.arrayCoor;
    newValue.mainMetric = mainMetric;
    this.setState({
      arrayCoor: newValue,
    });
    if (this.props.isAddCoordinate === false) {
      this.callBack();
    }
  };
Example #14
Source File: RegionClass.tsx    From grafana-weathermap-panel with Apache License 2.0 6 votes vote down vote up
constructor(
    id: number,
    linkURL: LinkURLClass,
    meta: Metadata[],
    lowerLimitClass: LowerLimitClass[],
    label: string,
    textObj: TextObject,
    mainMetric: Metric,
    metrics: Metric[],
    colorMode: boolean,
    traceBack: boolean,
    traceBorder: boolean,
    positionParameter: PositionParameterClass,
    idSVG: string,
    orientedLink: OrientedLinkClass[],
    coords: Coord4D,
    coordsDefault: Coord4D,
    mode: boolean,
    img: string,
    widthInitialSpaceDefault: string,
    heightInitialSpaceDefault: string
  ) {
    super(id, linkURL, meta, lowerLimitClass, label, textObj, mainMetric, metrics, colorMode, traceBack, traceBorder, positionParameter);
    this.idSVG = idSVG;
    this.mode = mode;
    this.orientedLink = orientedLink;
    this.coords = coords;
    this.coordsDefault = coordsDefault;
    this.img = img;
    this.widthInitialSpaceDefault = widthInitialSpaceDefault;
    this.heightInitialSpaceDefault = heightInitialSpaceDefault;
  }
Example #15
Source File: getResultQuery.tsx    From grafana-weathermap-panel with Apache License 2.0 6 votes vote down vote up
searchNameIsKey = (query: DataFrame, mainMetric: Metric): boolean => {
  if (mainMetric.key === '' && mainMetric.keyValue === '') {
    return true;
  }
  let remove = query.name?.split('{');
  const nameQuery: string[] =
    remove![1].split(',').flatMap((value) => {
      return value.replace(/[\"{}]/gm, '');
    }) || [];
  if (nameQuery && nameQuery.length > 0) {
    for (const oneQuery of nameQuery) {
      const keyValue: string[] = oneQuery.split('=');
      if (keyValue.length === 2) {
        if (keyValue[0] === mainMetric.key && keyValue[1] === mainMetric.keyValue) {
          return true;
        }
      }
    }
  }
  return false;
}
Example #16
Source File: CoordinateSpaceClass.tsx    From grafana-weathermap-panel with Apache License 2.0 6 votes vote down vote up
constructor(
    id: number,
    linkURL: LinkURLClass,
    meta: Metadata[],
    lowerLimit: LowerLimitClass[],
    label: string,
    textObj: TextObject,
    mainMetric: Metric,
    metrics: Metric[],
    colorMode: boolean,
    traceBack: boolean,
    traceBorder: boolean,
    positionParameter: PositionParameterClass
  ) {
    this.id = id;
    this.linkURL = linkURL;
    this.meta = meta;
    this.lowerLimit = lowerLimit;
    this.label = label;
    this.textObj = textObj;
    this.mainMetric = mainMetric;
    this.metrics = metrics;
    this.colorMode = colorMode;
    this.traceBack = traceBack;
    this.traceBorder = traceBorder;
    this.positionParameter = positionParameter;
  }
Example #17
Source File: CoordinateSpaceClass.tsx    From grafana-weathermap-panel with Apache License 2.0 5 votes vote down vote up
mainMetric: Metric;
Example #18
Source File: drawRectangleExtend.tsx    From grafana-weathermap-panel with Apache License 2.0 5 votes vote down vote up
getValuesAuxiliaryMetrics = (): string[] => {
    const region: RegionClass = this.props.uneCoor;
    reqMetricAuxRegion(region, this.props);
    const mainMetric: Metric = region.mainMetric;
    const auxiliaryMetrics: Metric[] = region.metrics;
    let valueAuxiliaryMetric: string[] = [];
    //const countMetrics: number = auxiliaryMetrics.length;
    auxiliaryMetrics.forEach((metric: Metric) => {
      let countTotalValues = 0;
      let resultTotalValues = 0;
      let result = '';
      if (metric.returnQuery && metric.returnQuery.length > 0) {
        let numberLoop: number = metric.returnQuery?.length || 0;
        if (metric.key !== '' && metric.keyValue !== '') {
          for (let i = 0; i < numberLoop; i++) {
            let line = metric.returnQuery[i];
            if (line.fields[0].labels) {
              if (mainMetric.refId !== '') {
                if (line.fields[0].labels[mainMetric.key] === mainMetric.keyValue || (mainMetric.key === '' && mainMetric.keyValue === '')) {
                  if (line.fields[0].labels[metric.key] === metric.keyValue) {
                    const countValues: number = line.fields[0].values.length;
                    for (let i = 0; i < countValues; i++) {
                      if (line.fields[0].values.get(i)) {
                        resultTotalValues += line.fields[0].values.get(i);
                        countTotalValues++;
                      }
                    }
                  }
                }
              }
            }
          }
        } else {
          for (let i = 0; i < numberLoop; i++) {
            let line = metric.returnQuery[i];
            if (line.fields[0].labels) {
              if (mainMetric.refId) {
                if (line.fields[0].labels[mainMetric.key] === mainMetric.keyValue || (mainMetric.key === '' && mainMetric.keyValue === '')) {
                  const countValues: number = line.fields[0].values.length;
                  for (let i = 0; i < countValues; i++) {
                    if (line.fields[0].values.get(i)) {
                      resultTotalValues += line.fields[0].values.get(i);
                      countTotalValues++;
                    }
                  }
                }
              }
            }
          }
        }
        if (metric.manageValue === 'avg') {
          result = (resultTotalValues / countTotalValues).toString();
        } else if (metric.manageValue === 'sum') {
          result = resultTotalValues.toString();
        } else if (metric.manageValue === 'err') {
          if (countTotalValues > 1) {
            result = 'error';
          } else {
            result = resultTotalValues.toString();
          }
        }
      }
      if (result !== '') {
        valueAuxiliaryMetric.push(result);
      }
    });
    return valueAuxiliaryMetric;
  };
Example #19
Source File: manageQuery.tsx    From grafana-weathermap-panel with Apache License 2.0 5 votes vote down vote up
/** update with promise mainMetric state */
  setStateAsyncMainMetricB = (state: {
    /** new value main metric */
    mainMetricB: Metric;
  }) => {
    return new Promise((resolve) => this.setState(state, resolve));
  };
Example #20
Source File: manageQuery.tsx    From grafana-weathermap-panel with Apache License 2.0 5 votes vote down vote up
/** update with promise mainMetric state */
  setStateAsyncMainMetric = (state: {
    /** new value main metric */
    mainMetric: Metric;
  }) => {
    return new Promise((resolve) => this.setState(state, resolve));
  };
Example #21
Source File: manageQuery.tsx    From grafana-weathermap-panel with Apache License 2.0 5 votes vote down vote up
/** add all query in select */
  fillSelectQuery = () => {
    const valueSelect: Array<SelectableValue<DataFrame>> = [];
    const newMainMetric: Metric = this.state.mainMetric;

    valueSelect.push({ value: undefined, label: 'No value' });
    for (const line of this.props.data.series) {
      let duplicate = false;
      for (const valueSave of valueSelect) {
        if (valueSave.value?.refId === line.refId) {
          duplicate = true;
          break;
        }
      }
      if (!duplicate) {
        valueSelect.push({ value: line, label: line.refId });
      }
    }
    if (newMainMetric.refId === '') {
      newMainMetric.refId = valueSelect.length > 0 ? valueSelect[0].value?.refId || '' : '';
    }

    const refId: string | undefined = this.state.mainMetric.refId;
    let defaultValue: SelectableValue<DataFrame>;

    defaultValue = { value: undefined, label: 'No value' };
    if (refId) {
      for (const line of valueSelect) {
        if (line.value?.refId === refId) {
          defaultValue = line;
          break;
        }
      }
    }
    this.setState({
      mainMetric: newMainMetric,
      selectQuery: valueSelect,
      selectQueryDefault: defaultValue,
    });
  };
Example #22
Source File: getResultQuery.tsx    From grafana-weathermap-panel with Apache License 2.0 5 votes vote down vote up
getResultQuery = (mainMetric: Metric) => {
  let cnt: number | null = null;
  if (mainMetric.returnQuery && mainMetric.returnQuery.length > 0) {
    const debug: number[] = [];
    let countValue = 0;

    cnt = 0;
    if (!mainMetric.filter) {
      for (const line of mainMetric.returnQuery) {
        const result = searchNameIsKey(line, mainMetric);
        if (result) {
          const sizeQuery: number = line.fields[0].values.length;
          // in grafana 7 change line.field[0] to line.field[1]
          for (let i = 0; i < sizeQuery; i++) {
            if (line.fields.length > 0 && line.fields[0].values.get(i)) {
              cnt += line.fields[0].values.get(i);
              debug.push(line.fields[0].values.get(i));
              ++countValue;
            }
          }
        }
      }
      if (mainMetric.manageValue === 'avg') {
        cnt /= countValue;
      } else if (mainMetric.manageValue === 'err') {
        if (countValue > 1) {
          cnt = null;
        }
      }
    } else {
      for (const line of mainMetric.returnQuery) {
        const result = searchNameIsFilter(line, mainMetric);
        if (result) {
          const sizeQuery: number = line.fields[0].values.length;
          // in grafana 7 change line.field[0] to line.field[1]
          for (let i = 0; i < sizeQuery; i++) {
            if (line.fields.length > 0 && line.fields[0].values.get(i)) {
              cnt += line.fields[0].values.get(i);
              debug.push(line.fields[0].values.get(i));
              ++countValue;
            }
          }
        }
      }
      if (mainMetric.manageValue === 'avg') {
        cnt /= countValue;
      } else if (mainMetric.manageValue === 'err') {
        if (countValue > 1) {
          cnt = null;
        }
      }
    }
  }

  return cnt;
}
Example #23
Source File: CoordinateSpaceClass.tsx    From grafana-weathermap-panel with Apache License 2.0 5 votes vote down vote up
metrics: Metric[];
Example #24
Source File: LinkClass.tsx    From grafana-weathermap-panel with Apache License 2.0 5 votes vote down vote up
constructor(
    id: number,
    linkURL: LinkURLClass,
    meta: Metadata[],
    lowerLimitClass: LowerLimitClass[],
    label: string,
    textObj: TextObject,
    mainMetric: Metric,
    metrics: Metric[],
    colorMode: boolean,
    traceBack: boolean,
    traceBorder: boolean,
    positionParameter: PositionParameterClass,
    name: string,
    defineHowToGetCoordonate: SelectableValue<string>,
    orientationLink: SelectableValue<string>,
    pointAPositionX: string,
    pointAPositionY: string,
    colorCoordinateA: string,
    pointBPositionX: string,
    pointBPositionY: string,
    colorCoordinateB: string,
    pointIn: SelectableValue<PointClass>,
    pointOut: SelectableValue<PointClass>,
    regionIn: SelectableValue<RegionClass>,
    colorRegionIn: string,
    regionOut: SelectableValue<RegionClass>,
    colorRegionOut: string,
    labelLinkA: string,
    positionXLabelA: string,
    positionYLabelA: string,
    labelLinkB: string,
    positionXLabelB: string,
    positionYLabelB: string
  ) {
    super(id, linkURL, meta, lowerLimitClass, label, textObj, mainMetric, metrics, colorMode, traceBack, traceBorder, positionParameter);
    this.name = name;
    this.defineHowToGetCoordonate = defineHowToGetCoordonate;
    this.orientationLink = orientationLink;
    this.pointAPositionX = pointAPositionX;
    this.pointAPositionY = pointAPositionY;
    this.colorCoordinateA = colorCoordinateA;
    this.pointBPositionX = pointBPositionX;
    this.pointBPositionY = pointBPositionY;
    this.colorCoordinateB = colorCoordinateB;
    this.pointIn = pointIn;
    this.pointOut = pointOut;
    this.regionIn = regionIn;
    this.colorRegionIn = colorRegionIn;
    this.regionOut = regionOut;
    this.colorRegionOut = colorRegionOut;
    this.labelLinkA = labelLinkA;
    this.positionXLabelA = positionXLabelA;
    this.positionYLabelA = positionYLabelA;
    this.labelLinkB = labelLinkB;
    this.positionXLabelB = positionXLabelB;
    this.positionYLabelB = positionYLabelB;
  }
Example #25
Source File: OrientedLinkClass.tsx    From grafana-weathermap-panel with Apache License 2.0 5 votes vote down vote up
constructor(
    id: number,
    linkURL: LinkURLClass,
    meta: Metadata[],
    lowerLimitClass: LowerLimitClass[],
    label: string,
    textObj: TextObject,
    mainMetric: Metric,
    metrics: Metric[],
    colorMode: boolean,
    traceBack: boolean,
    traceBorder: boolean,
    positionParameter: PositionParameterClass,
    name: string,
    orientationLink: SelectableValue<string>,
    size: string,
    pointAPositionX: string,
    pointAPositionY: string,
    colorCoordinateA: string,
    pointBPositionX: string,
    pointBPositionY: string,
    colorCoordinateB: string,
    valueMainMetricA: string,
    valueMainMetricB: string,
    pointIn: string,
    pointOut: string,
    regionIn: string,
    regionOut: string,
    zIndex: number,
    pointCPositionX: string,
    pointCPositionY: string,
    isIncurved: SelectableValue<boolean>,
    mainMetricB: Metric,
    metricsB: Metric[],
    widthInitialSpaceDefault: string,
    heightInitialSpaceDefault: string,
    pointAPositionXDefault: string,
    pointAPositionYDefault: string,
    pointBPositionXDefault: string,
    pointBPositionYDefault: string,
    pointCPositionXDefault: string,
    pointCPositionYDefault: string
  ) {
    super(id, linkURL, meta, lowerLimitClass, label, textObj, mainMetric, metrics, colorMode, traceBack, traceBorder, positionParameter);
    this.name = name;
    this.orientationLink = orientationLink;
    this.size = size;
    this.pointAPositionX = pointAPositionX;
    this.pointAPositionY = pointAPositionY;
    this.colorCoordinateA = colorCoordinateA;
    this.pointBPositionX = pointBPositionX;
    this.pointBPositionY = pointBPositionY;
    this.colorCoordinateB = colorCoordinateB;
    this.valueMainMetricA = valueMainMetricA;
    this.valueMainMetricB = valueMainMetricB;
    this.pointIn = pointIn;
    this.pointOut = pointOut;
    this.regionIn = regionIn;
    this.regionOut = regionOut;
    this.zIndex = zIndex;
    this.pointCPositionX = pointCPositionX;
    this.pointCPositionY = pointCPositionY;
    this.isIncurved = isIncurved;
    this.mainMetricB = mainMetricB;
    this.metricsB = metricsB;
    this.widthInitialSpaceDefault = widthInitialSpaceDefault;
    this.heightInitialSpaceDefault = heightInitialSpaceDefault;
    this.pointAPositionXDefault = pointAPositionXDefault;
    this.pointAPositionYDefault = pointAPositionYDefault;
    this.pointBPositionXDefault = pointBPositionXDefault;
    this.pointBPositionYDefault = pointBPositionYDefault;
    this.pointCPositionXDefault = pointCPositionXDefault;
    this.pointCPositionYDefault = pointCPositionYDefault;
  }
Example #26
Source File: OrientedLinkClass.tsx    From grafana-weathermap-panel with Apache License 2.0 5 votes vote down vote up
mainMetricB: Metric;
Example #27
Source File: OrientedLinkClass.tsx    From grafana-weathermap-panel with Apache License 2.0 5 votes vote down vote up
metricsB: Metric[];
Example #28
Source File: PointClass.tsx    From grafana-weathermap-panel with Apache License 2.0 5 votes vote down vote up
constructor(
    id: number,
    linkURL: LinkURLClass,
    meta: Metadata[],
    lowerLimitClass: LowerLimitClass[],
    label: string,
    textObj: TextObject,
    mainMetric: Metric,
    metrics: Metric[],
    colorMode: boolean,
    traceBack: boolean,
    traceBorder: boolean,
    positionParameter: PositionParameterClass,
    name: string,
    valueMetric: string,
    drawGraphicMarker: SelectableValue<string>,
    shape: SelectableValue<string>,
    //sizeWidth: SelectableValue<string>,
    sizeWidth: string,
    sizeHeight: SelectableValue<string>,
    rotateArrow: string,
    positionShapeX: string,
    positionShapeY: string,
    color: string,
    associateOrientedLinksIn: any[],
    associateOrientedLinksOut: any[],
    widthInitialSpaceDefault: string,
    heightInitialSpaceDefault: string,
    positionXDefault: string,
    positionYDefault: string
  ) {
    super(id, linkURL, meta, lowerLimitClass, label, textObj, mainMetric, metrics, colorMode, traceBack, traceBorder, positionParameter);
    this.name = name;
    this.valueMetric = valueMetric;
    this.drawGraphicMarker = drawGraphicMarker;
    this.shape = shape;
    this.sizeWidth = sizeWidth;
    this.sizeHeight = sizeHeight;
    this.rotateArrow = rotateArrow;
    this.positionShapeX = positionShapeX;
    this.positionShapeY = positionShapeY;
    this.color = color;
    this.associateOrientedLinksIn = associateOrientedLinksIn;
    this.associateOrientedLinksOut = associateOrientedLinksOut;
    this.widthInitialSpaceDefault = widthInitialSpaceDefault;
    this.heightInitialSpaceDefault = heightInitialSpaceDefault;
    this.positionXDefault = positionXDefault;
    this.positionYDefault = positionYDefault;
  }
Example #29
Source File: SimplePanel.tsx    From grafana-weathermap-panel with Apache License 2.0 5 votes vote down vote up
getValuesAuxiliaryMetrics = (auxiliaryMetrics: Metric[], mainMetric: Metric): string[] => {
    let valueAuxiliaryMetric: string[] = [];
    //const countMetrics: number = auxiliaryMetrics.length;
    if (auxiliaryMetrics.length < 1) {
      auxiliaryMetrics.forEach((metric: Metric) => {
        let countTotalValues = 0;
        let resultTotalValues = 0;
        let result = '';
        if (metric.returnQuery && metric.returnQuery.length > 0) {
          let numberLoop: number = metric.returnQuery?.length || 0;
          if (metric.key !== '' && metric.keyValue !== '') {
            for (let i = 0; i < numberLoop; i++) {
              let line = metric.returnQuery[i];
              if (line.fields[0].labels) {
                if (mainMetric.refId !== '') {
                  if (line.fields[0].labels[mainMetric.key] === mainMetric.keyValue || (mainMetric.key === '' && mainMetric.keyValue === '')) {
                    if (line.fields[0].labels[metric.key] === metric.keyValue) {
                      const countValues: number = line.fields[0].values.length;
                      for (let i = 0; i < countValues; i++) {
                        if (line.fields[0].values.get(i)) {
                          resultTotalValues += line.fields[0].values.get(i);
                          countTotalValues++;
                        }
                      }
                    }
                  }
                }
              }
            }
          } else {
            if (mainMetric.refId !== '') {
              for (let i = 0; i < numberLoop; i++) {
                let line = metric.returnQuery[i];
                if (line.fields[0].labels) {
                  if (line.fields[0].labels[mainMetric.key] === mainMetric.keyValue || (mainMetric.key === '' && mainMetric.keyValue === '')) {
                    const countValues: number = line.fields[0].values.length;
                    for (let i = 0; i < countValues; i++) {
                      if (line.fields[0].values.get(i)) {
                        resultTotalValues += line.fields[0].values.get(i);
                        countTotalValues++;
                      }
                    }
                  }
                }
              }
            }
          }
          if (metric.manageValue === 'avg') {
            result = (resultTotalValues / countTotalValues).toString();
          } else if (metric.manageValue === 'sum') {
            result = resultTotalValues.toString();
          } else if (metric.manageValue === 'err') {
            if (countTotalValues > 1) {
              result = 'error';
            } else {
              result = resultTotalValues.toString();
            }
          }
        }
        if (result !== '') {
          valueAuxiliaryMetric.push(result);
        }
      });
    }
    return valueAuxiliaryMetric;
  };