diff --git a/docker-compose.yml b/docker-compose.yml index dc2f622..d611bce 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,12 +4,14 @@ services: ports: - 2379:2379 - 2380:2370 + network_mode: host prometheus: build: docker/prometheus ports: - 9090:9090 depends_on: - node-exporter + network_mode: host panel: build: management-panel # volumes: @@ -31,4 +33,5 @@ services: volumes: - '/:/host:ro' opcua-exporter: - build: opcua-exporter \ No newline at end of file + build: opcua-exporter + network_mode: host \ No newline at end of file diff --git a/docker/prometheus/confd/confd.toml b/docker/prometheus/confd/confd.toml index 2fc4b41..35e7926 100644 --- a/docker/prometheus/confd/confd.toml +++ b/docker/prometheus/confd/confd.toml @@ -1,6 +1,6 @@ backend = "etcd" nodes = [ - "http://etcd:2379", + "http://127.0.0.1:2379", ] watch = true diff --git a/docker/prometheus/confd/templates/prometheus.tmpl b/docker/prometheus/confd/templates/prometheus.tmpl index 1b695de..fbb0ef4 100644 --- a/docker/prometheus/confd/templates/prometheus.tmpl +++ b/docker/prometheus/confd/templates/prometheus.tmpl @@ -5,12 +5,12 @@ scrape_configs: - job_name: 'node_exporter' scrape_interval: {{ getv "/time/node_exporter_scrape_interval"}}{{ getv "/time/node_exporter_scrape_interval_unit" }} static_configs: - - targets: [ 'node-exporter:9100' ] + - targets: [ '127.0.0.1:9100' ] - job_name: 'opcua_exporter' scrape_interval: {{ getv "/time/opcua_scrape_interval"}}{{ getv "/time/opcua_scrape_interval_unit" }} static_configs: - - targets: [ 'opcua-exporter:8191' ] + - targets: [ '127.0.0.1:8191' ] {{ if getv "/remote_write/state" }} remote_write: - url: {{ getv "/remote_write/url" }} diff --git a/docker/prometheus/prometheus.yml b/docker/prometheus/prometheus.yml index 63abd12..b119325 100644 --- a/docker/prometheus/prometheus.yml +++ b/docker/prometheus/prometheus.yml @@ -4,8 +4,8 @@ global: scrape_configs: - job_name: 'node_exporter' static_configs: - - targets: [ '172.17.0.1:9100' ] + - targets: [ '127.0.0.1:9100' ] - job_name: 'opcua_exporter' static_configs: - - targets: [ 'opcua-exporter:8191' ] \ No newline at end of file + - targets: [ '127.0.0.1:8191' ] \ No newline at end of file diff --git a/management-panel/Dockerfile b/management-panel/Dockerfile index e739f96..8cc5b7e 100644 --- a/management-panel/Dockerfile +++ b/management-panel/Dockerfile @@ -5,7 +5,7 @@ FROM openeuler/openeuler:24.03 AS dev # 更新系统和安装软件包 RUN dnf update -y && \ - dnf install -y git php-cli php-bcmath php-mbstring php-pdo php-pecl-zip php-opcache php-sodium php-intl php-pear php-devel c-ares-devel libcurl-devel openssl-devel brotli brotli-devel net-tools && \ + dnf install -y git php-cli php-bcmath php-mbstring php-pdo php-pecl-zip php-opcache php-sodium php-intl php-pear php-devel c-ares-devel libcurl-devel openssl-devel brotli brotli-devel net-tools NetworkManager && \ dnf clean all && \ rm -rf /var/cache/dnf/* @@ -43,7 +43,7 @@ RUN npm config set registry https://registry.npmmirror.com && \ FROM openeuler/openeuler:24.03 AS runtime RUN dnf update -y \ - && dnf install php-cli php-bcmath php-mbstring php-pdo php-pecl-zip php-posix php-sodium php-xml php-intl php-opcache c-ares libcurl openssl brotli net-tools -y \ + && dnf install php-cli php-bcmath php-mbstring php-pdo php-pecl-zip php-posix php-sodium php-xml php-intl php-opcache c-ares libcurl openssl brotli net-tools NetworkManager -y \ && dnf clean all && rm -rf /var/cache/dnf/* RUN mkdir -p /usr/lib64/php/modules/ diff --git a/management-panel/app/Services/EtcdService.php b/management-panel/app/Services/EtcdService.php index 1401155..9578693 100644 --- a/management-panel/app/Services/EtcdService.php +++ b/management-panel/app/Services/EtcdService.php @@ -6,7 +6,7 @@ use GuzzleHttp\Client; class EtcdService { protected $client; - protected $baseUri = 'http://etcd:2379/v3/'; // etcd 默认地址 + protected $baseUri = 'http://127.0.0.1:2379/v3/'; // etcd 默认地址 public function __construct() { diff --git a/management-panel/app/Services/PrometheusService.php b/management-panel/app/Services/PrometheusService.php index 390dd27..9dd16ac 100644 --- a/management-panel/app/Services/PrometheusService.php +++ b/management-panel/app/Services/PrometheusService.php @@ -6,7 +6,7 @@ use GuzzleHttp\Client; class PrometheusService { protected $client; - protected $baseUri = 'http://prometheus:9090/api/v1/'; // Prometheus 的默认地址 + protected $baseUri = 'http://127.0.0.1:9090/api/v1/'; // Prometheus 的默认地址 public function __construct() { diff --git a/opcua-exporter/confd/confd.toml b/opcua-exporter/confd/confd.toml index 2fc4b41..35e7926 100644 --- a/opcua-exporter/confd/confd.toml +++ b/opcua-exporter/confd/confd.toml @@ -1,6 +1,6 @@ backend = "etcd" nodes = [ - "http://etcd:2379", + "http://127.0.0.1:2379", ] watch = true