From bfec140d89de48a37721859e492c2a50c444c0fd Mon Sep 17 00:00:00 2001 From: zjwu10 Date: Mon, 10 Oct 2022 17:13:17 +0800 Subject: [PATCH 01/63] =?UTF-8?q?=E5=BE=AE=E6=9C=8D=E5=8A=A1=E5=AE=B9?= =?UTF-8?q?=E5=99=A8=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 36 +- docker/databases/docker-compose.yml | 6 +- docker/server/conf/apisix_conf/config.yaml | 61 + docker/server/conf/apisix_log/.keep | 0 docker/server/conf/apisix_log/nginx.pid | 1 + docker/server/conf/dashboard_conf/conf.yaml | 104 + docker/server/conf/etcd_conf/etcd.conf.yml | 157 ++ .../conf/grafana_conf/config/grafana.ini | 756 +++++++ .../dashboards/apisix-grafana-dashboard.json | 1782 +++++++++++++++++ .../provisioning/dashboards/all.yaml | 27 + .../provisioning/datasources/all.yaml | 25 + .../conf/prometheus_conf/prometheus.yml | 40 + docker/server/conf/upstream/web.conf | 24 + docker/server/docker-compose.yml | 137 +- docker/server/nginx.conf | 33 +- netaxe/Dockerfile | 4 +- netaxe/logs/error.log | 377 ++++ netaxe/logs/server.log | 517 +++++ netaxe/netboost/__init__.py | 6 + netaxe/netboost/settings.py | 90 +- netaxe/netboost/urls.py | 2 +- netaxe/requirements.txt | 8 +- netaxe/supervisord_prd.conf | 34 +- web/nginx.conf | 20 +- web/src/api/url.ts | 2 +- web/src/store/modules/user.ts | 2 +- 26 files changed, 4148 insertions(+), 103 deletions(-) create mode 100644 docker/server/conf/apisix_conf/config.yaml create mode 100644 docker/server/conf/apisix_log/.keep create mode 100644 docker/server/conf/apisix_log/nginx.pid create mode 100644 docker/server/conf/dashboard_conf/conf.yaml create mode 100644 docker/server/conf/etcd_conf/etcd.conf.yml create mode 100644 docker/server/conf/grafana_conf/config/grafana.ini create mode 100644 docker/server/conf/grafana_conf/dashboards/apisix-grafana-dashboard.json create mode 100644 docker/server/conf/grafana_conf/provisioning/dashboards/all.yaml create mode 100644 docker/server/conf/grafana_conf/provisioning/datasources/all.yaml create mode 100644 docker/server/conf/prometheus_conf/prometheus.yml create mode 100644 docker/server/conf/upstream/web.conf create mode 100644 netaxe/logs/error.log create mode 100644 netaxe/logs/server.log diff --git a/.gitignore b/.gitignore index a364921..0da1aae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,27 +1,31 @@ +venv/ +.git .idea -netaxe/netboost/conf.py -web/node_modules +.github +*.py[cod] +*$py.class +__pycache__/ web/.DS_Store web/dist web/*.local web/.idea/ web/.vscode/ -__pycache__/ -*.py[cod] -*$py.class -venv/ -netaxe/apps/api/__pycache__/ -netaxe/apps/asset/__pycache__/ -netaxe/apps/config_center/__pycache__/ -netaxe/apps/automation/__pycache__/ +web/node_modules +netaxe/__pycahe__ +Python-3.9.11.tgz +netaxe/netboost/conf.py netaxe/netboost/__pycache__/ +netaxe/apps/system/migrations/ netaxe/apps/api/migrations/ +netaxe/apps/api/__pycache__/ netaxe/apps/asset/migrations/ -netaxe/apps/config_center/migrations/ +netaxe/apps/asset/__pycache__/ netaxe/apps/automation/migrations/ -netaxe/apps/system/migrations/ -Python-3.9.11.tgz -netaxe/media/device_config/current-configuration -netaxe/media/automation +netaxe/apps/automation/__pycache__/ +netaxe/apps/config_center/migrations/ +netaxe/apps/config_center/__pycache__/ netaxemedia -netaxe/__pycahe__ +netaxe/media/automation +netaxe/media/device_config/current-configuration +docker/databases/init/ +docker/databases/mysql_data/ \ No newline at end of file diff --git a/docker/databases/docker-compose.yml b/docker/databases/docker-compose.yml index f66ad6b..72b773b 100644 --- a/docker/databases/docker-compose.yml +++ b/docker/databases/docker-compose.yml @@ -25,9 +25,9 @@ services: networks: - netops-databases - mongo-db: + mongodb: image: registry.cn-hangzhou.aliyuncs.com/netaxe/mongo:latest - container_name: mongo-db + container_name: mongodb restart: always ports: - "27017:27017" @@ -52,7 +52,7 @@ services: container_name: mongo-express restart: always depends_on: - - mongo-db + - mongodb ports: - 27018:8081 environment: diff --git a/docker/server/conf/apisix_conf/config.yaml b/docker/server/conf/apisix_conf/config.yaml new file mode 100644 index 0000000..48f1143 --- /dev/null +++ b/docker/server/conf/apisix_conf/config.yaml @@ -0,0 +1,61 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +apisix: + node_listen: 9080 # APISIX listening port + enable_ipv6: false + + allow_admin: # http://nginx.org/en/docs/http/ngx_http_access_module.html#allow + - 0.0.0.0/0 # We need to restrict ip access rules for security. 0.0.0.0/0 is for test. + + admin_key: + - name: "admin" + key: edd1c9f034335f136f87ad84b625c8f1 + role: admin # admin: manage all configuration data + # viewer: only can view configuration data + - name: "viewer" + key: 4054f7cf07e344346cd3f287985e76a2 + role: viewer + + enable_control: true + control: + ip: "0.0.0.0" + port: 9092 + +etcd: + host: # it's possible to define multiple etcd hosts addresses of the same etcd cluster. + - "http://10.254.2.189:2379" # multiple etcd address + prefix: "/apisix" # apisix configurations prefix + timeout: 30 # 30 seconds + +plugin_attr: + prometheus: + export_addr: + ip: "0.0.0.0" + port: 9091 + +discovery: + nacos: + host: + - "http://nacos:nacos@10.254.2.188:8848" + prefix: "/nacos/v1/" + fetch_interval: 30 # default 30 sec + weight: 100 # default 100 + timeout: + connect: 2000 # default 2000 ms + send: 2000 # default 2000 ms + read: 5000 # default 5000 ms diff --git a/docker/server/conf/apisix_log/.keep b/docker/server/conf/apisix_log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/docker/server/conf/apisix_log/nginx.pid b/docker/server/conf/apisix_log/nginx.pid new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/docker/server/conf/apisix_log/nginx.pid @@ -0,0 +1 @@ +1 diff --git a/docker/server/conf/dashboard_conf/conf.yaml b/docker/server/conf/dashboard_conf/conf.yaml new file mode 100644 index 0000000..a5a2f08 --- /dev/null +++ b/docker/server/conf/dashboard_conf/conf.yaml @@ -0,0 +1,104 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +conf: + listen: + host: 0.0.0.0 # `manager api` listening ip or host name + port: 9000 # `manager api` listening port + allow_list: # If we don't set any IP list, then any IP access is allowed by default. + - 0.0.0.0/0 + etcd: + endpoints: # supports defining multiple etcd host addresses for an etcd cluster + - "http://etcd:2379" + # yamllint disable rule:comments-indentation + # etcd basic auth info + # username: "root" # ignore etcd username if not enable etcd auth + # password: "123456" # ignore etcd password if not enable etcd auth + mtls: + key_file: "" # Path of your self-signed client side key + cert_file: "" # Path of your self-signed client side cert + ca_file: "" # Path of your self-signed ca cert, the CA is used to sign callers' certificates + # prefix: /apisix # apisix config's prefix in etcd, /apisix by default + log: + error_log: + level: warn # supports levels, lower to higher: debug, info, warn, error, panic, fatal + file_path: + logs/error.log # supports relative path, absolute path, standard output + # such as: logs/error.log, /tmp/logs/error.log, /dev/stdout, /dev/stderr + access_log: + file_path: + logs/access.log # supports relative path, absolute path, standard output + # such as: logs/access.log, /tmp/logs/access.log, /dev/stdout, /dev/stderr + # log example: 2020-12-09T16:38:09.039+0800 INFO filter/logging.go:46 /apisix/admin/routes/r1 {"status": 401, "host": "127.0.0.1:9000", "query": "asdfsafd=adf&a=a", "requestId": "3d50ecb8-758c-46d1-af5b-cd9d1c820156", "latency": 0, "remoteIP": "127.0.0.1", "method": "PUT", "errs": []} +authentication: + secret: + secret # secret for jwt token generation. + # NOTE: Highly recommended to modify this value to protect `manager api`. + # if it's default value, when `manager api` start, it will generate a random string to replace it. + expire_time: 3600 # jwt token expire time, in second + users: # yamllint enable rule:comments-indentation + - username: admin # username and password for login `manager api` + password: admin + - username: user + password: user + +plugins: # plugin list (sorted in alphabetical order) + - api-breaker + - authz-keycloak + - basic-auth + - batch-requests + - consumer-restriction + - cors + # - dubbo-proxy + - echo + # - error-log-logger + # - example-plugin + - fault-injection + - grpc-transcode + - hmac-auth + - http-logger + - ip-restriction + - jwt-auth + - kafka-logger + - key-auth + - limit-conn + - limit-count + - limit-req + # - log-rotate + # - node-status + - openid-connect + - prometheus + - proxy-cache + - proxy-mirror + - proxy-rewrite + - redirect + - referer-restriction + - request-id + - request-validation + - response-rewrite + - serverless-post-function + - serverless-pre-function + # - skywalking + - sls-logger + - syslog + - tcp-logger + - udp-logger + - uri-blocker + - wolf-rbac + - zipkin + - server-info + - traffic-split diff --git a/docker/server/conf/etcd_conf/etcd.conf.yml b/docker/server/conf/etcd_conf/etcd.conf.yml new file mode 100644 index 0000000..1152953 --- /dev/null +++ b/docker/server/conf/etcd_conf/etcd.conf.yml @@ -0,0 +1,157 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# This is the configuration file for the etcd server. + +# Human-readable name for this member. +name: 'default' + +# Path to the data directory. +data-dir: + +# Path to the dedicated wal directory. +wal-dir: + +# Number of committed transactions to trigger a snapshot to disk. +snapshot-count: 10000 + +# Time (in milliseconds) of a heartbeat interval. +heartbeat-interval: 100 + +# Time (in milliseconds) for an election to timeout. +election-timeout: 1000 + +# Raise alarms when backend size exceeds the given quota. 0 means use the +# default quota. +quota-backend-bytes: 0 + +# List of comma separated URLs to listen on for peer traffic. +listen-peer-urls: http://localhost:2380 + +# List of comma separated URLs to listen on for client traffic. +listen-client-urls: http://localhost:2379 + +# Maximum number of snapshot files to retain (0 is unlimited). +max-snapshots: 5 + +# Maximum number of wal files to retain (0 is unlimited). +max-wals: 5 + +# Comma-separated white list of origins for CORS (cross-origin resource sharing). +cors: + +# List of this member's peer URLs to advertise to the rest of the cluster. +# The URLs needed to be a comma-separated list. +initial-advertise-peer-urls: http://localhost:2380 + +# List of this member's client URLs to advertise to the public. +# The URLs needed to be a comma-separated list. +advertise-client-urls: http://localhost:2379 + +# Discovery URL used to bootstrap the cluster. +discovery: + +# Valid values include 'exit', 'proxy' +discovery-fallback: 'proxy' + +# HTTP proxy to use for traffic to discovery service. +discovery-proxy: + +# DNS domain used to bootstrap initial cluster. +discovery-srv: + +# Initial cluster configuration for bootstrapping. +initial-cluster: + +# Initial cluster token for the etcd cluster during bootstrap. +initial-cluster-token: 'etcd-cluster' + +# Initial cluster state ('new' or 'existing'). +initial-cluster-state: 'new' + +# Reject reconfiguration requests that would cause quorum loss. +strict-reconfig-check: false + +# Accept etcd V2 client requests +enable-v2: true + +# Enable runtime profiling data via HTTP server +enable-pprof: true + +# Valid values include 'on', 'readonly', 'off' +proxy: 'off' + +# Time (in milliseconds) an endpoint will be held in a failed state. +proxy-failure-wait: 5000 + +# Time (in milliseconds) of the endpoints refresh interval. +proxy-refresh-interval: 30000 + +# Time (in milliseconds) for a dial to timeout. +proxy-dial-timeout: 1000 + +# Time (in milliseconds) for a write to timeout. +proxy-write-timeout: 5000 + +# Time (in milliseconds) for a read to timeout. +proxy-read-timeout: 0 + +client-transport-security: + # Path to the client server TLS cert file. + cert-file: + + # Path to the client server TLS key file. + key-file: + + # Enable client cert authentication. + client-cert-auth: false + + # Path to the client server TLS trusted CA cert file. + trusted-ca-file: + + # Client TLS using generated certificates + auto-tls: false + +peer-transport-security: + # Path to the peer server TLS cert file. + cert-file: + + # Path to the peer server TLS key file. + key-file: + + # Enable peer client cert authentication. + client-cert-auth: false + + # Path to the peer server TLS trusted CA cert file. + trusted-ca-file: + + # Peer TLS using generated certificates. + auto-tls: false + +# Enable debug-level logging for etcd. +debug: false + +logger: zap + +# Specify 'stdout' or 'stderr' to skip journald logging even when running under systemd. +log-outputs: [stderr] + +# Force to create a new one member cluster. +force-new-cluster: false + +auto-compaction-mode: periodic +auto-compaction-retention: "1" diff --git a/docker/server/conf/grafana_conf/config/grafana.ini b/docker/server/conf/grafana_conf/config/grafana.ini new file mode 100644 index 0000000..cb6a737 --- /dev/null +++ b/docker/server/conf/grafana_conf/config/grafana.ini @@ -0,0 +1,756 @@ +##################### Grafana Configuration Example ##################### +# +# Everything has defaults so you only need to uncomment things you want to +# change + +# possible values : production, development +;app_mode = production + +# instance name, defaults to HOSTNAME environment variable value or hostname if HOSTNAME var is empty +;instance_name = ${HOSTNAME} + +#################################### Paths #################################### +[paths] +# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used) +;data = /var/lib/grafana + +# Temporary files in `data` directory older than given duration will be removed +;temp_data_lifetime = 24h + +# Directory where grafana can store logs +;logs = /var/log/grafana + +# Directory where grafana will automatically scan and look for plugins +;plugins = /var/lib/grafana/plugins + +# folder that contains provisioning config files that grafana will apply on startup and while running. +;provisioning = conf/provisioning + +#################################### Server #################################### +[server] +# Protocol (http, https, h2, socket) +;protocol = http + +# The ip address to bind to, empty will bind to all interfaces +;http_addr = + +# The http port to use +;http_port = 3000 + +# The public facing domain name used to access grafana from a browser +;domain = localhost + +# Redirect to correct domain if host header does not match domain +# Prevents DNS rebinding attacks +;enforce_domain = false + +# The full public facing url you use in browser, used for redirects and emails +# If you use reverse proxy and sub path specify full url (with sub path) +;root_url = %(protocol)s://%(domain)s:%(http_port)s/ + +# Serve Grafana from subpath specified in `root_url` setting. By default it is set to `false` for compatibility reasons. +;serve_from_sub_path = false + +# Log web requests +;router_logging = false + +# the path relative working path +;static_root_path = public + +# enable gzip +;enable_gzip = false + +# https certs & key file +;cert_file = +;cert_key = + +# Unix socket path +;socket = + +#################################### Database #################################### +[database] +# You can configure the database connection by specifying type, host, name, user and password +# as separate properties or as on string using the url properties. + +# Either "mysql", "postgres" or "sqlite3", it's your choice +;type = sqlite3 +;host = 127.0.0.1:3306 +;name = grafana +;user = root +# If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;""" +;password = + +# Use either URL or the previous fields to configure the database +# Example: mysql://user:secret@host:port/database +;url = + +# For "postgres" only, either "disable", "require" or "verify-full" +;ssl_mode = disable + +;ca_cert_path = +;client_key_path = +;client_cert_path = +;server_cert_name = + +# For "sqlite3" only, path relative to data_path setting +;path = grafana.db + +# Max idle conn setting default is 2 +;max_idle_conn = 2 + +# Max conn setting default is 0 (mean not set) +;max_open_conn = + +# Connection Max Lifetime default is 14400 (means 14400 seconds or 4 hours) +;conn_max_lifetime = 14400 + +# Set to true to log the sql calls and execution times. +;log_queries = + +# For "sqlite3" only. cache mode setting used for connecting to the database. (private, shared) +;cache_mode = private + +#################################### Cache server ############################# +[remote_cache] +# Either "redis", "memcached" or "database" default is "database" +;type = database + +# cache connectionstring options +# database: will use Grafana primary database. +# redis: config like redis server e.g. `addr=127.0.0.1:6379,pool_size=100,db=0,ssl=false`. Only addr is required. ssl may be 'true', 'false', or 'insecure'. +# memcache: 127.0.0.1:11211 +;connstr = + +#################################### Data proxy ########################### +[dataproxy] + +# This enables data proxy logging, default is false +;logging = false + +# How long the data proxy should wait before timing out default is 30 (seconds) +;timeout = 30 + +# If enabled and user is not anonymous, data proxy will add X-Grafana-User header with username into the request, default is false. +;send_user_header = false + +#################################### Analytics #################################### +[analytics] +# Server reporting, sends usage counters to stats.grafana.org every 24 hours. +# No ip addresses are being tracked, only simple counters to track +# running instances, dashboard and error counts. It is very helpful to us. +# Change this option to false to disable reporting. +;reporting_enabled = true + +# Set to false to disable all checks to https://grafana.net +# for new vesions (grafana itself and plugins), check is used +# in some UI views to notify that grafana or plugin update exists +# This option does not cause any auto updates, nor send any information +# only a GET request to http://grafana.com to get latest versions +;check_for_updates = true + +# Google Analytics universal tracking code, only enabled if you specify an id here +;google_analytics_ua_id = + +# Google Tag Manager ID, only enabled if you specify an id here +;google_tag_manager_id = + +#################################### Security #################################### +[security] +# disable creation of admin user on first start of grafana +;disable_initial_admin_creation = false + +# default admin user, created on startup +;admin_user = admin + +# default admin password, can be changed before first start of grafana, or in profile settings +;admin_password = admin + +# used for signing +;secret_key = SW2YcwTIb9zpOOhoPsMm + +# disable gravatar profile images +;disable_gravatar = false + +# data source proxy whitelist (ip_or_domain:port separated by spaces) +;data_source_proxy_whitelist = + +# disable protection against brute force login attempts +;disable_brute_force_login_protection = false + +# set to true if you host Grafana behind HTTPS. default is false. +;cookie_secure = false + +# set cookie SameSite attribute. defaults to `lax`. can be set to "lax", "strict", "none" and "disabled" +;cookie_samesite = none + +# set to true if you want to allow browsers to render Grafana in a ,