Promtail Stage Camelcase - grafana-loki

Can anyone help on how to transform incoming JSON text to camelcase in Promtail?
I am thinking of using the ToLower function and some kidn of trimming as described in: https://grafana.com/docs/loki/latest/clients/promtail/stages/template/#tolower--toupper
{
"Timestamp": "2022-11-17T07:58:15.6253633Z",
"Message": "An unhandled exception has occurred while executing the request.",
"Level": "Error",
"Exception": "Exception Text"
}
Should be
{
"timestamp": "2022-11-17T07:58:15.6253633Z",
"message": "An unhandled exception has occurred while executing the request.",
"level": "Error",
"exception": "Exception Text"
}
Anyone did something similar or have any advice on how to transform to camelcase?

Related

Behat is stop because there is an exception

i have problem. My api-platfrom works ok, this return status code 409.
{
"type": "https:\/\/tools.ietf.org\/html\/rfc2616#section-10",
"title": "An error occurred",
"detail": "nip: This value is already used.",
"trace": [...]
}
...but my behat tests is not works. They stop because there is an exception.
Scenario: Write a new legal entity with nip is exists in database
Given I am logged as user 1
When I add "Content-Type" header equal to "application/json"
When I add "Accept" header equal to "application/json"
#this return response status code 409, but api platform throw exception
And I send a "POST" request to "/legal-entities"
"""json
{
"name": "Andrzej",
"nip": "3784696345",
"email": "fake1#email.com",
"url": null,
"addressLine1": "Andrzejów",
"addressLine2": "2",
"postcode": "00-000",
"province": "Lubelskie",
"city": "Andrzejowo",
"countryIso2": "PL"
}
"""
Then the response status code should be 409
i got failed tests https://i.stack.imgur.com/UaL6P.png
how fix them?

provisionCOmposer.js returns error message of "bad host name"

I am following the standard bot framework composer deployment script, as following:
cmd_prompts> node provisionComposer.js
--tenantId=<my tenantid>
--subscriptionId=<my subscriptionid>...
It was working pretty well at the beginning. Then it failed after I deleted several existing resources from my subscription. The following is a copy of the error returned by the provisionComposer.js script:
{
"Code": "BadRequest",
"Message": "The host name nyname01-xyz_env.azurewebsites.net is invalid.",
"Target": null,
"Details": [
{
"Message": "The host name nyname01-xyz_env.azurewebsites.net is invalid."
},
{
"Code": "BadRequest"
},
{
"ErrorEntity": {
"ExtendedCode": "04003",
"MessageTemplate": "The host name {0} is invalid.",
"Parameters": [
"nyname01-xyz_env.azurewebsites.net"
],
"Code": "BadRequest",
"Message": "The host name nyname01-xyz_env.azurewebsites.net is invalid."
}
}
],
"Innererror": null
}
Result:
Provision failed
Can anyone shed some light? Appreciate your help.

Spring Boot 2.3+ no longer prints useful errors information for validation (from MethodArgumentNotValidException)

I have a user request payload
class UserRequest {
#NotBlank
String firstName;
#NotBlank
String lastName;
#Min(18)
#Max(65)
Integer age;
..
}
Starting with 2.3+, I have enabled below to show error message:
server:
error:
include-message: always
Which works fine but it no longer shows errors that I used to see if there was a validation error:
{
"timestamp": "2020-10-08T20:27:18.834+00:00",
"status": 400,
"error": "Bad Request",
"message": "Validation failed for object='userRequest'. Error count: 2",
"path": "/user"
}
Above isn't very descriptive to the end user what failed the validation, as opposed to previous versions with a errors field:
{
"timestamp": "2020-10-08T20:27:18.834+00:00",
"status": 400,
"error": "Bad Request",
"errors": [
{
"codes": [..],
"arguments": [..],
"defaultMessage": "must be greater than or equal to 18
},
{
...
}
]
"message": "Validation failed for object='userRequest'. Error count: 2",
"path": "/user"
}
Is there any easy way to enable back old behavior or do I have to provide custom exception handling through some ControllerAdvice?

Cant print the error message in console from object

I receive the following object error:
"error": {
"errors": [
{
"domain": "global",
"reason": "authError",
"message": "Invalid Credentials",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Invalid Credentials"
}
}
I'd like to call an action when the error code is 401 or message is "Invalid Credentials" but the following code does nothing and when I try do console.error("got something:", err["code"]); to log in the console it comes blank:
console.error("got something:", err["code"]);
if (err["code"]=="401") {
console.log("Found error: 401");
this.messageServ.presentMessage("auth_error");
}
return err;
Looks like your not access fields deep enough in your object graph
Try this:
err["error"]["code"]

https://usercontent.googleapis.com/freebase/v1/imageID return "Domain Type Forbidden"

https://usercontent.googleapis.com/freebase/v1/image/en/jenni_rivera
https://usercontent.googleapis.com/freebase/v1/image/en/bob_dylan
return
{
"error": {
"errors": [
{
"domain": "global",
"reason": "domainTypeForbidden",
"message": "Domain Type Forbidden"
}
],
"code": 403,
"message": "Domain Type Forbidden"
}
}
Do i do somthing wrong? API was changed?
Yes, we're looking into it. Right now the images are available from:
https://www.googleapis.com/freebase/v1/image/en/jenni_rivera
...but it should be switched back to usercontent.googleapis.com very soon.

Resources