-
Notifications
You must be signed in to change notification settings - Fork 12.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert field type problems - out of a Loki datasource #63947
Comments
@grafana/dashboards-squad could you please a look at this one? If there’s anything we can help with, just ping us. Thanks! |
I removed Loki label as this seems like an issue with transformations and not issue with Loki data source. |
EDIT: Apologies, appears to have already been resolved in the above listed PR. It appears the file function fieldToNumberField(field: Field): Field {
const numValues = field.values.toArray().slice();
// in my case, numValues appears to be [undefined, "2.3", undefined, "12.1", ...]
const valuesAsStrings = numValues.some((v) => typeof v === 'string');
for (let n = 0; n < numValues.length; n++) {
let toBeConverted = numValues[n];
if (valuesAsStrings) {
// some numbers returned from datasources have commas
// strip the commas, coerce the string to a number
toBeConverted = toBeConverted.replace(/,/g, '');
}
const number = +toBeConverted;
numValues[n] = Number.isFinite(number) ? number : null;
}
return {
...field,
type: FieldType.number,
values: new ArrayVector(numValues),
};
} This does not account for sparse data, where some of the records have if (valuesAsStrings) {
// some numbers returned from datasources have commas
// strip the commas, coerce the string to a number
toBeConverted = toBeConverted.replace(/,/g, '');
} errors as Could this be simply remedied with the following snipped? if (valuesAsStrings && toBeConverted) { // check toBeConverted exists.
// some numbers returned from datasources have commas
// strip the commas, coerce the string to a number
toBeConverted = toBeConverted.replace(/,/g, '');
} |
Fixed in #66807 The fix will be out in Grafana 10 |
I have a problem to convert the filed type to number as the datasource is from Loki:
As an example I get 3 Values from an ordinary grafana.log:
Value 1 is a DATE, The user-ID stands for NUMBER 1 and the duration for NUMBER 2. Just to have some numbers.
Out of Loki, all the values are string type values.
To create a graph, I have to convert them to numbers.
Here is what happend..:
when I convert them to number - it crashed. Cant do that.
This problem occures since Grafana 9.3.6
more examples in the community
Anything else we need to know?:
Environment:
Hope someone can help and fix the situation.
In my case I can fix the problem by convert to json and not to number.
The text was updated successfully, but these errors were encountered: