亚洲视频二区_亚洲欧洲日本天天堂在线观看_日韩一区二区在线观看_中文字幕不卡一区

公告:魔扣目錄網(wǎng)為廣大站長(zhǎng)提供免費(fèi)收錄網(wǎng)站服務(wù),提交前請(qǐng)做好本站友鏈:【 網(wǎng)站目錄:http://www.430618.com 】, 免友鏈快審服務(wù)(50元/站),

點(diǎn)擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會(huì)員:747

本文介紹了利用千分尺實(shí)現(xiàn)新型文物與彈簧靴的集成的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我正在嘗試使用測(cè)微計(jì)將一個(gè)簡(jiǎn)單的Spring Boot應(yīng)用程序與New Relic集成。

以下是配置詳細(xì)信息:-

application.properties

management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always

management.metrics.export.newrelic.enabled=true
management.metrics.export.newrelic.api-key:MY_API_KEY // Have added the API key here
management.metrics.export.newrelic.account-id: MY_ACCOUNT_ID // Have added the account id here
logging.level.io.micrometer.newrelic=TRACE

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.5</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>springboot.micrometer.demo</groupId>
    <artifactId>micrometer-new-relic</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>micrometer-new-relic</name>
    <description>Demo project for actuator integration with new relic using micrometer</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-new-relic</artifactId>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-prometheus</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

我能夠使用micrometer-registry-prometheus依賴項(xiàng)將Prometheus與此應(yīng)用程序集成。我將普羅米修斯設(shè)置為在本地系統(tǒng)的Docker容器中運(yùn)行。我使用了以下一組命令-

docker pull prom/prometheus
docker run -p 9090:9090 -v D:/Workspaces/STS/server_sent_events_blog/micrometer-new-relic/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus

prometheus.yml

global:
  scrape_interval: 4s
  evaluation_interval: 4s

scrape_configs:
  - job_name: 'spring_micrometer'
    metrics_path: '/actuator/prometheus'
    scrape_interval: 5s
    static_configs:
      - targets: ['my_ip_address:8080']

當(dāng)我導(dǎo)航到localhost:9090/targets時(shí),我可以看到Prometheus儀表板顯示了我的應(yīng)用程序詳細(xì)信息,并且可以從中獲取數(shù)據(jù)。在儀表板中,我還可以看到我的自定義指標(biāo)以及其他指標(biāo)。

所以我的問(wèn)題是,我想使用New Relic實(shí)現(xiàn)相同的功能。我已經(jīng)添加了micrometer-registry-new-relicPOM依賴項(xiàng)。我也分享了application.properties文件。我可以在我的控制臺(tái)中看到日志,說(shuō)明它正在向New Relic發(fā)送數(shù)據(jù)-

2021-10-24 12:42:04.889 DEBUG 2672 --- [trics-publisher] i.m.n.NewRelicInsightsApiClientProvider : successfully sent 58 metrics to New Relic.

問(wèn)題:

    下一步是什么?
    我是否需要一個(gè)本地運(yùn)行的New Relic服務(wù)器,就像我為普羅米修斯做的那樣?
    我可以在哪里可視化此數(shù)據(jù)?我在New Relic有一個(gè)賬戶,在那里我什么也看不到

https://discuss.newrelic.com/t/integrate-spring-boot-actuator-with-new-relic/126732
根據(jù)上面的鏈接,Spring Bootctuator將指標(biāo)作為事件類型”SpringBootSample”進(jìn)行推送。
使用NRQL查詢,我們可以確認(rèn)這一點(diǎn)-

FROM SpringBootSample SELECT max(value) TIMESERIES 1 minute WHERE metricName = 'jvmMemoryCommitted'

    此查詢的結(jié)果表明什么?它是與我的應(yīng)用程序相關(guān)的指標(biāo)嗎?

這里是我在這里分享的演示的GitHub link。
我沒(méi)有找到任何關(guān)于這方面的明確說(shuō)明,有一些例子,但使用Java代理。

我們將非常感謝您的任何幫助。

推薦答案

根據(jù)我目前所學(xué)。
有三種方法可以將New Relic與Spring Boot應(yīng)用程序集成-

    使用New Relic提供的Java代理
    使用New Relic的千分尺依賴
    千分表的新遺跡依賴

1.使用New Relic提供的Java代理進(jìn)行配置

    從此URL下載Java代理-https://docs.newrelic.com/docs/release-notes/agent-release-notes/java-release-notes/
    提取它。
    修改解壓縮文件夾中的newrelic.yml文件以包含您的
    許可證密鑰(_K):
    應(yīng)用程序名稱:
    創(chuàng)建具有一些REST終結(jié)點(diǎn)的SpringBoot應(yīng)用程序。
    生成應(yīng)用程序。
    導(dǎo)航到您解壓了newRelic Java代理的根路徑。
    輸入此命令
    java -javagent:<path to your new relic jar>
    ewrelic.jar -jar <path to your application jar><you rapplication jar name>.jar

查看應(yīng)用程序指標(biāo)-

    登錄到您的新文物帳戶。
    轉(zhuǎn)到資源管理器選項(xiàng)卡。
    點(diǎn)擊服務(wù)-APM
    您可以在那里看到您的應(yīng)用程序的名稱(您在newrelic.yml文件中提到過(guò))。
    單擊應(yīng)用程序名稱。
    儀表板應(yīng)如下所示。

使用New Relic的微米依賴項(xiàng)是執(zhí)行此操作的首選方法。

2.使用New Relic的微米依賴項(xiàng)進(jìn)行配置

    添加此依賴項(xiàng)
<dependency>
        <groupId>com.newrelic.telemetry</groupId>
        <artifactId>micrometer-registry-new-relic</artifactId>
        <version>0.7.0</version>
    </dependency>
    修改MicrometerConfig.java類以添加您的API密鑰和應(yīng)用程序名稱。
import java.net.InetAddress;
import java.net.UnknownHostException;

import org.springframework.boot.actuate.autoconfigure.metrics.CompositeMeterRegistryAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.newrelic.telemetry.Attributes;
import com.newrelic.telemetry.micrometer.NewRelicRegistry;
import com.newrelic.telemetry.micrometer.NewRelicRegistryConfig;

import java.time.Duration;
import io.micrometer.core.instrument.config.MeterFilter;
import io.micrometer.core.instrument.util.NamedThreadFactory;

@Configuration
@AutoConfigureBefore({ CompositeMeterRegistryAutoConfiguration.class, SimpleMetricsExportAutoConfiguration.class })
@AutoConfigureAfter(MetricsAutoConfiguration.class)
@ConditionalOnClass(NewRelicRegistry.class)
public class MicrometerConfig {

    @Bean
    public NewRelicRegistryConfig newRelicConfig() {
        return new NewRelicRegistryConfig() {
            @Override
            public String get(String key) {
                return null;
            }

            @Override
            public String apiKey() {
                return "your_api_key"; // for production purposes take it from config file
            }

            @Override
            public Duration step() {
                return Duration.ofSeconds(5);
            }

            @Override
            public String serviceName() {
                return "your_service_name"; // take it from config file
            }

        };
    }

    @Bean
    public NewRelicRegistry newRelicMeterRegistry(NewRelicRegistryConfig config) throws UnknownHostException {
        NewRelicRegistry newRelicRegistry = NewRelicRegistry.builder(config)
                .commonAttributes(new Attributes().put("host", InetAddress.getLocalHost().getHostName())).build();
        newRelicRegistry.config().meterFilter(MeterFilter.ignoreTags("plz_ignore_me"));
        newRelicRegistry.config().meterFilter(MeterFilter.denyNameStartsWith("jvm.threads"));
        newRelicRegistry.start(new NamedThreadFactory("newrelic.micrometer.registry"));
        return newRelicRegistry;
    }
}
    運(yùn)行應(yīng)用程序。

查看應(yīng)用程序指標(biāo)-

    登錄到您的新文物帳戶。
    轉(zhuǎn)到資源管理器選項(xiàng)卡。
    點(diǎn)擊服務(wù)-開(kāi)放遙測(cè)
    您可以在那里看到您的應(yīng)用程序的名稱(您在MicrometerConfig文件中提到過(guò))。
    單擊應(yīng)用程序名稱。
    儀表板應(yīng)如下所示。

這篇關(guān)于利用千分尺實(shí)現(xiàn)新型文物與彈簧靴的集成的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,

分享到:
標(biāo)簽:利用 千分尺 彈簧 文物 集成
用戶無(wú)頭像

網(wǎng)友整理

注冊(cè)時(shí)間:

網(wǎng)站:5 個(gè)   小程序:0 個(gè)  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會(huì)員

趕快注冊(cè)賬號(hào),推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨(dú)大挑戰(zhàn)2018-06-03

數(shù)獨(dú)一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過(guò)答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫(kù),初中,高中,大學(xué)四六

運(yùn)動(dòng)步數(shù)有氧達(dá)人2018-06-03

記錄運(yùn)動(dòng)步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績(jī)?cè)u(píng)定2018-06-03

通用課目體育訓(xùn)練成績(jī)?cè)u(píng)定