2

运行atlas1.4.7

下载地址

curl -Lo memory.conf https://raw.githubusercontent.com/Netflix/atlas/master/conf/memory.conf
java -jar atlas-1.4.7-standalone.jarmemory.conf

或者使用docker

FROM netflixoss/java:8
MAINTAINER Netflix Open Source Development <talent@netflix.com>

RUN apt-get -qq update &&\
    apt-get -qq -y install ca-certificates &&\
    mkdir -p /apps/atlas &&\
    wget -q -P /apps/atlas 'https://github.com/Netflix/atlas/releases/download/v1.4.7/atlas-1.4.7-standalone.jar'

ADD ./memory.conf /apps/atlas/memory.conf

EXPOSE 7101

ENTRYPOINT ["/usr/bin/java", "-jar", "/apps/atlas/atlas-1.4.7-standalone.jar","/apps/atlas/memory.conf"]

CMD ["run"]

运行

docker build -t atlas:1.4.7 .
docker run --name atlas --rm -p 7101:7101  atlas:1.4.7

访问http://192.168.99.100:7101/ap...检查服务是否正常启动

maven

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-spectator</artifactId>
        </dependency>

        <dependency>
            <groupId>com.netflix.spectator</groupId>
            <artifactId>spectator-ext-jvm</artifactId>
            <version>0.40.0</version>
        </dependency>
        <dependency>
            <groupId>com.netflix.spectator</groupId>
            <artifactId>spectator-ext-gc</artifactId>
            <version>0.51.0</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-atlas</artifactId>
        </dependency>

java配置

@EnableAtlas
@Configuration
public class AtlasTagProviderConfigration {
    @Bean
    AtlasTagProvider atlasCommonTags(@Value("${spring.application.name}") String appName) {
        return () -> Collections.singletonMap("app", appName);
    }

    @Bean
    public CommandLineRunner registerExtMetrics(Registry registry) {
        return new CommandLineRunner() {
            @Override
            public void run(String... strings) throws Exception {
                Jmx.registerStandardMXBeans(registry);
                Spectator.globalRegistry().add(registry);
                GcLogger gc = new GcLogger();
                gc.start(null);
            }
        };
    }

}

altas服务地址配置

netflix:
  atlas:
    uri: http://192.168.99.100:7101/api/v1/publish/

altas查询

Stack-Language

http://192.168.99.100:7101/api/v1/graph?q=app,review,:eq,statistic,count,:eq,:and&tz=Asia/Shanghai
http://192.168.99.100:7101/api/v1/graph?q=app,review,:eq,name,jvm.memory.used,:eq,:and&tz=Asia/Shanghai
http://192.168.99.100:7101/api/v1/graph?q=app,review,:eq,name,jvm.gc.promotionRate,:eq,:and&tz=Asia/Shanghai
http://192.168.99.100:7101/api/v1/graph?q=app,review,:eq,name,jvm.gc.liveDataSize,:eq,:and&tz=Asia/Shanghai
http://192.168.99.100:7101/api/v1/graph?q=app,review,:eq,name,jvm.gc.pause,:eq,:and&tz=Asia/Shanghai
http://192.168.99.100:7101/api/v1/graph?q=app,review,:eq,name,jvm.gc.allocationRate,:eq,:and&tz=Asia/Shanghai
http://192.168.99.100:7101/api/v1/graph?q=app,review,:eq,name,jvm.gc.pause,:eq,statistic,count,:eq,:and,:and&tz=Asia/Shanghai

截图

  • jvm.gc.allocationRate
    图片描述

  • jvm.gc.promotionRate
    图片描述

  • jvm.memory.used
    图片描述

  • jvm.gc.pause
    图片描述

doc


codecraft
11.9k 声望2k 粉丝

当一个代码的工匠回首往事时,不因虚度年华而悔恨,也不因碌碌无为而羞愧,这样,当他老的时候,可以很自豪告诉世人,我曾经将代码注入生命去打造互联网的浪潮之巅,那是个很疯狂的时代,我在一波波的浪潮上留下...