These are chat archives for spring-cloud/spring-cloud

9th
Aug 2018
Knut Schleßelmann
@kschlesselmann
Aug 09 2018 07:49

Hi guys, I'm still trying to add cloudwatch metrics to my application. Currently I have

dependencyManagement {
    imports {
        mavenBom 'org.springframework.cloud:spring-cloud-aws:2.0.0.RELEASE'
    }
}

dependencies {
    compile('com.fasterxml.jackson.module:jackson-module-kotlin')
    compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    compile("org.jetbrains.kotlin:kotlin-reflect")

    //compile('org.springframework.boot:spring-boot-starter-actuator')
    compile('org.springframework.boot:spring-boot-starter-webflux')

    compile('org.springframework.cloud:spring-cloud-starter-aws')
    compile('org.springframework.cloud:spring-cloud-aws-actuator')

    compile("org.apache.commons:commons-compress:1.17")
    compile("io.github.microutils:kotlin-logging:1.5.9")

    runtime('org.springframework.boot:spring-boot-devtools')

    kapt('org.springframework.boot:spring-boot-configuration-processor')

    testCompile('org.springframework.boot:spring-boot-starter-test') {
        exclude module: 'junit'
    }
    testCompile('io.projectreactor:reactor-test')
    testImplementation('org.junit.jupiter:junit-jupiter-api')
    testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine')
}

in my build.gradle and

management:
  metrics:
    export:
      cloudwatch:
        enabled: true
        namespace: my-service

in my configuration. But it seems there are not metrics written. Any suggestions?

The config properties aren't regiocnized by my IDE as well … this feels wrong
Szymon Zberaz
@SzymonZberaz_twitter
Aug 09 2018 11:51
@kschlesselmann check this tutorial http://dkublik.github.io/springboot-metrics-with-servo-and-aws-cloudwatch/
Knut Schleßelmann
@kschlesselmann
Aug 09 2018 12:00
@SzymonZberaz_twitter Yeah, I already found that … but currently I got some exception. So I think I'm on some valid path :-)
Brian Devins-Suresh
@devinsba
Aug 09 2018 13:44
@kschlesselmann I think you need to include spring-boot-starter-actuator as well
Knut Schleßelmann
@kschlesselmann
Aug 09 2018 13:48
@devinsba Yeah I did … it's working now. Sadly my jenkins test fail now because of … is not authorized to perform: cloudformation:DescribeStackResources (Service: AmazonCloudFormation; Status Code: 403; Error Code: AccessDenied; … if I run tests that start a Spring context … I think it's detecting that it runs on some EC2 (jenkins) and tries to start up its Spring Cloud AWS magic
Brian Devins-Suresh
@devinsba
Aug 09 2018 13:54
I excluded aws-java-sdk-cloudformation and aws-java-sdk-s3 from spring-cloud-starter-aws since I wasn’t using those to ignore those auto configurations
Knut Schleßelmann
@kschlesselmann
Aug 09 2018 13:55
Hm … maybe that's an idea as well …
Do you have something along
cloud:
  aws:
    region:
      static: eu-central-1
in application-test.yml as well? @devinsba
Brian Devins-Suresh
@devinsba
Aug 09 2018 13:58
Yeah
Knut Schleßelmann
@kschlesselmann
Aug 09 2018 14:00

OK, jenkins is up and running again :-)

Let's see what this cloudformation stuff did in the first place :-P

Sarvesh Dubey
@Sarvesh-D
Aug 09 2018 15:31
Hi is there a document to know the order in which spring events are published. I am looking for an event which will be published after the spring context is refreshed (especially after hitting the /refresh endpoint) and after the Eureka client registers itself. Currently it has been a trial and error for me. I tried to listen to RefreshScopeRefreshedEvent, it triggers when I hit the refresh endpoint, but post refresh the client registers to Eureka server. My use case is to send some metadata to Eureka after the client is refreshed.
Sarvesh Dubey
@Sarvesh-D
Aug 09 2018 18:55
@spencergibb thanks for the links. But I am still not able to achieve my use case. I want to send some dynamically generated metadata for a client to Eureka. Everything works fine when the client registers to Eureka during app startup, but when I hit the refresh endpoint all that metadata gets lost. So I registered an InstanceRegisteredEvent listener which will update the metadata using /apps/appId/instanceId?metadata API. I am fetching the instance I'd by doing GET for ` The tricky part is when the instance gets refresh, it re-registers itself to Eureka due to which a new instanceId is created
So when I do try to get all instances of the app from Eureka using REST API, sometimes it gives me the old instance Id due to which the update metadata API fails. As a workaround, I used spring retry with some delay and eventually the GET API returns proper instance Id and the update metadata succeeds. But looks like I am complicating stuff to do a simple thing (to update client metadata on refresh so that it is not lost), any suggestions?
Sarvesh Dubey
@Sarvesh-D
Aug 09 2018 19:04
Not sure if I was clear on explaining the problem, if not let me know, I will post question on Stack overflow
Marcos Barbero
@marcosbarbero
Aug 09 2018 20:49
@Sarvesh-D I was working on something similar few months ago, if you can share some code on a public repo I'll be more than happy to help you out