mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Prometheus: Fix numeric values in raw prometheus view which are being formatted as text (#69737)
* output numeric if exists * fix bug where copying to clipboard was excluding quantile label (le)
This commit is contained in:
@@ -108,7 +108,7 @@ const RawListItem = ({ listItemData, listKey, totalNumberOfValues, valueLabels,
|
|||||||
* Transform the symbols in the dataFrame to uniform strings
|
* Transform the symbols in the dataFrame to uniform strings
|
||||||
*/
|
*/
|
||||||
const transformCopyValue = (value: string): string => {
|
const transformCopyValue = (value: string): string => {
|
||||||
if (value === '∞') {
|
if (value === '∞' || value === 'Infinity') {
|
||||||
return '+Inf';
|
return '+Inf';
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
@@ -117,7 +117,7 @@ const RawListItem = ({ listItemData, listKey, totalNumberOfValues, valueLabels,
|
|||||||
// Convert the object back into a string
|
// Convert the object back into a string
|
||||||
const stringRep = `${__name__}{${attributeValues.map((value) => {
|
const stringRep = `${__name__}{${attributeValues.map((value) => {
|
||||||
// For histograms the string representation currently in this object is not directly queryable in all situations, leading to broken copied queries. Omitting the attribute from the copied result gives a query which returns all le values, which I assume to be a more common use case.
|
// For histograms the string representation currently in this object is not directly queryable in all situations, leading to broken copied queries. Omitting the attribute from the copied result gives a query which returns all le values, which I assume to be a more common use case.
|
||||||
return value.key !== 'le' ? `${value.key}="${transformCopyValue(value.value)}"` : '';
|
return `${value.key}="${transformCopyValue(value.value)}"`;
|
||||||
})}}`;
|
})}}`;
|
||||||
|
|
||||||
const hideFieldsWithoutValues = Boolean(valueLabels && valueLabels?.length);
|
const hideFieldsWithoutValues = Boolean(valueLabels && valueLabels?.length);
|
||||||
|
|||||||
@@ -38,11 +38,17 @@ export const getRawPrometheusListItemsFromDataFrame = (dataFrame: DataFrame): in
|
|||||||
if (label !== 'Time') {
|
if (label !== 'Time') {
|
||||||
// Initialize the objects
|
// Initialize the objects
|
||||||
if (typeof field?.display === 'function') {
|
if (typeof field?.display === 'function') {
|
||||||
const stringValue = formattedValueToString(field?.display(field.values[i]));
|
const value = field?.display(field.values[i]);
|
||||||
if (stringValue) {
|
if (!isNaN(value.numeric)) {
|
||||||
formattedMetric[label] = stringValue;
|
formattedMetric[label] = value.numeric.toString(10);
|
||||||
} else if (label.includes('Value #')) {
|
} else {
|
||||||
formattedMetric[label] = RawPrometheusListItemEmptyValue;
|
const stringValue = formattedValueToString(value);
|
||||||
|
|
||||||
|
if (stringValue) {
|
||||||
|
formattedMetric[label] = stringValue;
|
||||||
|
} else if (label.includes('Value #')) {
|
||||||
|
formattedMetric[label] = RawPrometheusListItemEmptyValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.warn('Field display method is missing!');
|
console.warn('Field display method is missing!');
|
||||||
|
|||||||
Reference in New Issue
Block a user