0

In my application.yml of my spring boot app I want to configure the actuator metrics to push to my elastic server.

 metrics:
    enable:
        all: false
        diskspace: true
        jvm: true
        mycustomstuff: true

    export:
        elastic:
            enabled: true
            host: https://${vcap.services.my-cloud-logging.credentials.Elasticsearch-endpoint}
            password: ${vcap.services.my-cloud-logging.credentials.Elasticsearch-password}
            user-name: ${vcap.services.my-cloud-logging.credentials.Elasticsearch-username}
            auto-create-index: false
            index: metrics

But micrometer keeps failing when sending metrics because my variable is not well expended

 Illegal character in authority at index 8: https://${vcap.services.my-cloud-logging.credentials.Elasticsearch-endpoint}/metrics-2021-10/_bulk"

I checked at runtime all the variables have the correct value. They are created by CloudFoundryVcapEnvironmentPostProcesso.

Actually, I have the feeling the problem is caused by the concatenation of "https://" with the variable.

Also confirmed by this unanswered question, where the OP wants to prepend "jdbc:" to a vcap variable

Using double quotes as "host: https://${vcap.services.my-cloud-logging.credentials.Elasticsearch-endpoint}" didn't help

MiniScalope
  • 1,429
  • 1
  • 16
  • 22
  • What version of Spring Boot are you using? I just tested this with 2.5.5 and it works for me. I can set `url: "jdbc:${url}?useSSL=true&requireSSL=true&verifyServerCertificate=true"` in aplication.yml and run my app with `URL=db.example.com ./mvnw spring-boot:run` and it'll print `jdbc:db.example.com?useSSL=true&requireSSL=true&verifyServerCertificate=true`. Similar post where it's also working: https://stackoverflow.com/a/54911958/1585136 – Daniel Mikusa Oct 28 '21 at 15:00
  • Also, you might want to comment out the bits that are failing, run your app and take a look at the `/actuator/env` endpoint. It'll show you what properties are set, so you can see if perhaps something is missing that you expected to be there. Side note, you can also set `VCAP_SERVICES` locally, just copy the contents of the env variable from your CF environment and set that env locally. Then you can run with a debugger and investigate what's not working for you. – Daniel Mikusa Oct 28 '21 at 15:06

0 Answers0