Grafana: unable to create dashboards and datasources from other admin-tools
Problem
When deploying loki, the datasource is not created:
Get token
parse error: Invalid numeric literal at line 1, column 7
Get folder ID
jq: error (at <stdin>:1): null (null) cannot be matched, as it is not a string
Create datasource
{"extra":null,"message":"Unauthorized","messageId":"auth.unauthorized","statusCode":401,"traceID":""}
<html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx</center>
</body>
</html>
The issue is because the base64 command wrap it's output lines:
- short strings are not wrapped:
pwgen -s1 42 | tr -d '\n' | base64SDRrZEtVUzlDTnVPbkVVMEZRQlpHcldaNGtwd05OREYyOXkzc0tLWUZq - long strings are wrapped:
pwgen -s1 128 | tr -d '\n' | base64c3diMU43SWVndlA5Y3p4ZThYM0Q2NUM1Q3RYUTJtNkMyRzF1TllsZTNqMzdDdlBTaTZ4YmZqcGtP NjBLSzB5ODVISEtBMmo2MXdFYk5ZaVFqR2xQY1hVbDVhNm0zNlpYQkxtbEJEVDRtNW5aZGVGZnJM MnNHNzVoZUxmSU02eUw=
After working around this problem, I found that the datasource:
- do not use the correct URL with custom namespace
- use hard coded
nameandtypein the macro
Promtail client URL could be calculated automatically, I think.
Proposal
- Use the
-w0option to avoid wrapping base64:pwgen -s1 128 | tr -d '\n' | base64 -w0Y01qQmxSNUwxRHlBUHV4RFhDblRDTlhMSUsxdDlGYllnZUZsZ1hTUWhvNXlDSUZST2s1eDhCM0FzR2ZiRTFKSE90MlVDZkdDZE95blhwZ2YzaFBHNVZWTEhsZ2plajRkMllDQXYzRFNCYzVvRERKZmF2TmRtUHpKUEpaNVlJOUM= - use the
namespacedefined by configuration to create datasource - make the
nameandtypeconfigurable
Modification effectuée par Daniel Dehennin