gpt4 book ai didi

angular - 弹性APM Opentracing在Docker apm-server中遇到CORS问题

转载 作者:行者123 更新时间:2023-12-02 22:47:49 26 4
gpt4 key购买 nike

给定此docker文件以设置后端服务,其中包括:elasticsearch,apm服务器,kibana,jaeger-collector,jaeger-agent,jaeger-query,grafana。

apm-server:
image: docker.elastic.co/apm/apm-server:6.8.1
ports:
- 8200:8200
environment:
- output.elasticsearch.hosts=['http://elasticsearch:9200']
- apm-server.host="0.0.0.0:8200"
- apm-server.rum.enabled=true
- setup.kibana.host="kibana:5601"
- setup.template.enabled=true
- logging.to_files=false
networks:
- elastic-jaeger

我正在从Angular客户端运行带有Opentracing的Elastic APM:
const elasticApm = initApm({
serviceName: `Test`,
serviceUrl: `127.0.0.1:8200`,
// serviceVersion: ``,
active: true,
environment: ``, // production, development, test, etc
logLevel: `warn`, // Possible levels are: trace, debug, info, warn, error
flushInterval: 500, // ms
errorThrottleLimit: 20, // errors
errorThrottleInterval: 30000, // ms
transactionSampleRate: 1.0,
distributedTracing: true,
distributedTracingOrigins: ['http://foo.com']
});

const elasticTracer = createTracer(elasticApm);
this.opentracing.initGlobalTracer(elasticTracer);

我遇到CORS问题:

Screenshot of CORS error

我的目标是将 flex APM的opentracing客户端Angular连接到docker内部的服务。

还有一些其他问题和文档涵盖了apm-server的CORS:

Distributed Tracing Guide

Config with RUM enabled

由于 Default value is set to ['*'], which allows everything.,因此配置似乎可以正常工作

最佳答案

尝试使用配置:

version: "3"

services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.8.1
networks:
- elastic-jaeger
ports:
- "127.0.0.1:9200:9200"
- "127.0.0.1:9300:9300"
restart: on-failure
environment:
- cluster.name=jaeger-cluster
- discovery.type=single-node
- http.host=0.0.0.0
- transport.host=127.0.0.1
- ES_JAVA_OPTS=-Xms512m -Xmx512m
- xpack.security.enabled=false
volumes:
- esdata:/usr/share/elasticsearch/data

apm-server:
image: docker.elastic.co/apm/apm-server:6.8.1
ports:
- 8200:8200

volumes:
- ./apm-server/config/apm-server.yml:/usr/share/apm-server/apm-server.yml

networks:
- elastic-jaeger

kibana:
image: docker.elastic.co/kibana/kibana:6.8.1
ports:
- "127.0.0.1:5601:5601"
restart: on-failure
networks:
- elastic-jaeger

jaeger-collector:
image: jaegertracing/jaeger-collector
ports:
- "14269:14269"
- "14268:14268"
- "14267:14267"
- "9411:9411"
networks:
- elastic-jaeger
restart: on-failure
environment:
- SPAN_STORAGE_TYPE=elasticsearch
command: [
"--es.server-urls=http://elasticsearch:9200",
"--es.num-shards=1",
"--es.num-replicas=0",
"--log-level=error"
]
depends_on:
- elasticsearch

jaeger-agent:
image: jaegertracing/jaeger-agent
hostname: jaeger-agent
command: ["--collector.host-port=jaeger-collector:14267"]
ports:
- "5775:5775/udp"
- "6831:6831/udp"
- "6832:6832/udp"
- "5778:5778"
networks:
- elastic-jaeger
restart: on-failure
environment:
- SPAN_STORAGE_TYPE=elasticsearch
depends_on:
- jaeger-collector

jaeger-query:
image: jaegertracing/jaeger-query
environment:
- SPAN_STORAGE_TYPE=elasticsearch
- no_proxy=localhost
ports:
- "16686:16686"
- "16687:16687"
networks:
- elastic-jaeger
restart: on-failure
command: [
"--es.server-urls=http://elasticsearch:9200",
"--span-storage.type=elasticsearch",
"--log-level=debug"
]
depends_on:
- jaeger-agent

grafana:
image: grafana/grafana
ports:
- 3999:3000
volumes:
- ./grafana-data:/var/lib/grafana
networks:
- elastic-jaeger

volumes:
esdata:
driver: local

networks:
elastic-jaeger:
driver: bridge


其中文件apm-server / config / apm-server.yml具有您的配置内容:
apm-server.rum.enabled: true
apm-server.rum.event_rate.limit: 300
apm-server.rum.event_rate.lru_size: 1000
apm-server.rum.allow_origins: ['*']
apm-server.rum.library_pattern: "node_modules|bower_components|~"
apm-server.rum.exclude_from_grouping: "^/webpack"
apm-server.rum.source_mapping.cache.expiration: 5m
apm-server.rum.source_mapping.index_pattern: "apm-*-sourcemap*"
output.elasticsearch.hosts: ["http://elasticsearch:9200"]
apm-server.host: "0.0.0.0:8200"
setup.kibana.host: "kibana:5601"
setup.template.enabled: true
logging.to_files: false


注意您可以配置为解决CORS问题的rum.allow_origins选项。 https://www.elastic.co/guide/en/apm/agent/rum-js/master/configuring-cors.html

关于angular - 弹性APM Opentracing在Docker apm-server中遇到CORS问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57211703/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com