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:
parent
a02bf1104c
commit
093d0a4c35
@ -108,7 +108,7 @@ const RawListItem = ({ listItemData, listKey, totalNumberOfValues, valueLabels,
|
||||
* Transform the symbols in the dataFrame to uniform strings
|
||||
*/
|
||||
const transformCopyValue = (value: string): string => {
|
||||
if (value === '∞') {
|
||||
if (value === '∞' || value === 'Infinity') {
|
||||
return '+Inf';
|
||||
}
|
||||
return value;
|
||||
@ -117,7 +117,7 @@ const RawListItem = ({ listItemData, listKey, totalNumberOfValues, valueLabels,
|
||||
// Convert the object back into a string
|
||||
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.
|
||||
return value.key !== 'le' ? `${value.key}="${transformCopyValue(value.value)}"` : '';
|
||||
return `${value.key}="${transformCopyValue(value.value)}"`;
|
||||
})}}`;
|
||||
|
||||
const hideFieldsWithoutValues = Boolean(valueLabels && valueLabels?.length);
|
||||
|
@ -38,11 +38,17 @@ export const getRawPrometheusListItemsFromDataFrame = (dataFrame: DataFrame): in
|
||||
if (label !== 'Time') {
|
||||
// Initialize the objects
|
||||
if (typeof field?.display === 'function') {
|
||||
const stringValue = formattedValueToString(field?.display(field.values[i]));
|
||||
if (stringValue) {
|
||||
formattedMetric[label] = stringValue;
|
||||
} else if (label.includes('Value #')) {
|
||||
formattedMetric[label] = RawPrometheusListItemEmptyValue;
|
||||
const value = field?.display(field.values[i]);
|
||||
if (!isNaN(value.numeric)) {
|
||||
formattedMetric[label] = value.numeric.toString(10);
|
||||
} else {
|
||||
const stringValue = formattedValueToString(value);
|
||||
|
||||
if (stringValue) {
|
||||
formattedMetric[label] = stringValue;
|
||||
} else if (label.includes('Value #')) {
|
||||
formattedMetric[label] = RawPrometheusListItemEmptyValue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.warn('Field display method is missing!');
|
||||
|
Loading…
Reference in New Issue
Block a user