LogstashUI 0.5.5.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- AI/__init__.py +0 -0
- AI/integration_factory.py +1392 -0
- AI/migrations/0001_initial.py +58 -0
- AI/migrations/0002_draftdefinition_normalizers.py +23 -0
- AI/migrations/0003_delete_aisettings_delete_draftdefinition.py +19 -0
- AI/migrations/__init__.py +0 -0
- AI/models.py +5 -0
- AI/static/js/integration_factory.js +1102 -0
- AI/system_prompts/dashboard_generator.md +367 -0
- AI/system_prompts/grok_patterns.txt +95 -0
- AI/system_prompts/ingest_pipeline_generator.md +331 -0
- AI/system_prompts/ingest_pipeline_processors.json +2851 -0
- AI/system_prompts/ingest_verifier.md +84 -0
- AI/system_prompts/integrations_list.json +2690 -0
- AI/system_prompts/log_classifier.md +134 -0
- AI/system_prompts/template_creator.md +123 -0
- AI/templates/integration_factory.html +200 -0
- AI/urls.py +16 -0
- AI/views.py +20 -0
- API/__init__.py +0 -0
- API/admin.py +7 -0
- API/api.http +784 -0
- API/apps.py +9 -0
- API/auth.py +101 -0
- API/connections_views.py +312 -0
- API/guides.py +88 -0
- API/mcp/__init__.py +5 -0
- API/mcp/dispatch.py +179 -0
- API/mcp/tools.py +890 -0
- API/mcp/views.py +215 -0
- API/migrations/__init__.py +0 -0
- API/models.py +7 -0
- API/pipelines_views.py +1224 -0
- API/policies_views.py +1015 -0
- API/security_views.py +488 -0
- API/simulation_detail.py +219 -0
- API/snmp_views.py +1539 -0
- API/urls.py +81 -0
- Common/__init__.py +0 -0
- Common/ai/agent_builder.py +690 -0
- Common/context_processors.py +49 -0
- Common/decorators.py +68 -0
- Common/elastic_utils.py +1154 -0
- Common/encryption.py +271 -0
- Common/error_handlers.py +65 -0
- Common/formatters.py +106 -0
- Common/logstash_config_parse.py +1469 -0
- Common/logstash_utils.py +34 -0
- Common/middleware.py +216 -0
- Common/product_ca.py +1124 -0
- Common/validators.py +66 -0
- Documentation/__init__.py +0 -0
- Documentation/admin.py +7 -0
- Documentation/apps.py +9 -0
- Documentation/content/CHANGELOG.md +890 -0
- Documentation/content/docs/getting_started.md +92 -0
- Documentation/content/docs/index.md +124 -0
- Documentation/content/docs/logstashagent/configuration/index.md +60 -0
- Documentation/content/docs/logstashagent/configuration/logstashagent.yml.md +141 -0
- Documentation/content/docs/logstashagent/general/build.md +217 -0
- Documentation/content/docs/logstashagent/general/index.md +38 -0
- Documentation/content/docs/logstashagent/general/roles.md +267 -0
- Documentation/content/docs/logstashagent/index.md +264 -0
- Documentation/content/docs/logstashui/SNMP/Quickstart.md +94 -0
- Documentation/content/docs/logstashui/SNMP/architecture.md +64 -0
- Documentation/content/docs/logstashui/SNMP/configuration.md +147 -0
- Documentation/content/docs/logstashui/SNMP/data_overview.md +59 -0
- Documentation/content/docs/logstashui/SNMP/deploying_changes.md +71 -0
- Documentation/content/docs/logstashui/SNMP/device_support.md +39 -0
- Documentation/content/docs/logstashui/SNMP/discovery.md +48 -0
- Documentation/content/docs/logstashui/SNMP/index.md +58 -0
- Documentation/content/docs/logstashui/SNMP/pipeline_generation.md +63 -0
- Documentation/content/docs/logstashui/SNMP/schema.md +595 -0
- Documentation/content/docs/logstashui/SNMP/testing.md +47 -0
- Documentation/content/docs/logstashui/SNMP/traps.md +45 -0
- Documentation/content/docs/logstashui/SNMP/tsds_implementation.md +82 -0
- Documentation/content/docs/logstashui/agent_guides/concepts.md +25 -0
- Documentation/content/docs/logstashui/agent_guides/deploy.md +30 -0
- Documentation/content/docs/logstashui/agent_guides/pipeline-review.md +24 -0
- Documentation/content/docs/logstashui/agent_guides/simulation.md +55 -0
- Documentation/content/docs/logstashui/agent_guides/snmp.md +57 -0
- Documentation/content/docs/logstashui/agent_guides/troubleshooting.md +21 -0
- Documentation/content/docs/logstashui/architecture.md +11 -0
- Documentation/content/docs/logstashui/compatibility.md +58 -0
- Documentation/content/docs/logstashui/configuration/environment.md +193 -0
- Documentation/content/docs/logstashui/configuration/host_mode.md +94 -0
- Documentation/content/docs/logstashui/configuration/index.md +72 -0
- Documentation/content/docs/logstashui/configuration/logstash_proxy.md +138 -0
- Documentation/content/docs/logstashui/configuration/logstashui.yml.md +16 -0
- Documentation/content/docs/logstashui/configuration/simulation.md +84 -0
- Documentation/content/docs/logstashui/database/examples/README.md +15 -0
- Documentation/content/docs/logstashui/database/examples/create-mariadb.sql +13 -0
- Documentation/content/docs/logstashui/database/examples/create-mysql.sql +12 -0
- Documentation/content/docs/logstashui/database/examples/create-postgresql.sql +13 -0
- Documentation/content/docs/logstashui/database/examples/schema-mysql.sql +502 -0
- Documentation/content/docs/logstashui/database/examples/schema-postgresql.sql +1709 -0
- Documentation/content/docs/logstashui/database/index.md +79 -0
- Documentation/content/docs/logstashui/database/migration.md +75 -0
- Documentation/content/docs/logstashui/general/build.md +154 -0
- Documentation/content/docs/logstashui/general/deploy.md +122 -0
- Documentation/content/docs/logstashui/general/deployment-recs.md +32 -0
- Documentation/content/docs/logstashui/general/index.md +62 -0
- Documentation/content/docs/logstashui/general/offline.md +68 -0
- Documentation/content/docs/logstashui/general/updating.md +50 -0
- Documentation/content/docs/logstashui/index.md +90 -0
- Documentation/content/docs/logstashui/kubernetes/cnpg.md +98 -0
- Documentation/content/docs/logstashui/kubernetes/envoy-gateway.md +112 -0
- Documentation/content/docs/logstashui/kubernetes/examples/README.md +46 -0
- Documentation/content/docs/logstashui/kubernetes/examples/embedded-agent.yaml +122 -0
- Documentation/content/docs/logstashui/kubernetes/examples/mysql/configmap.yaml +41 -0
- Documentation/content/docs/logstashui/kubernetes/examples/mysql/ingress.yaml +31 -0
- Documentation/content/docs/logstashui/kubernetes/examples/mysql/namespace.yaml +8 -0
- Documentation/content/docs/logstashui/kubernetes/examples/mysql/secret.yaml +19 -0
- Documentation/content/docs/logstashui/kubernetes/examples/mysql/statefulset.yaml +106 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/cnpg.yaml +25 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/configmap.yaml +42 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/ingress.yaml +31 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/namespace.yaml +8 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/secret.yaml +19 -0
- Documentation/content/docs/logstashui/kubernetes/examples/postgresql/statefulset.yaml +106 -0
- Documentation/content/docs/logstashui/kubernetes/examples/sqlite/configmap.yaml +35 -0
- Documentation/content/docs/logstashui/kubernetes/examples/sqlite/ingress.yaml +31 -0
- Documentation/content/docs/logstashui/kubernetes/examples/sqlite/namespace.yaml +8 -0
- Documentation/content/docs/logstashui/kubernetes/examples/sqlite/secret.yaml +18 -0
- Documentation/content/docs/logstashui/kubernetes/examples/sqlite/statefulset.yaml +106 -0
- Documentation/content/docs/logstashui/kubernetes/index.md +121 -0
- Documentation/content/docs/logstashui/mcp.md +224 -0
- Documentation/content/docs/logstashui/mcp_scenarios.md +234 -0
- Documentation/content/docs/logstashui/rest_api.md +2783 -0
- Documentation/content/docs/logstashui/utilities/dissect_debugger.md +89 -0
- Documentation/content/docs/logstashui/utilities/grok_debugger.md +114 -0
- Documentation/content/docs/logstashui/utilities/index.md +40 -0
- Documentation/content/images/LogstashIcon.png +0 -0
- Documentation/content/images/architecture.png +0 -0
- Documentation/content/images/connection_manager.png +0 -0
- Documentation/content/images/control_plane.png +0 -0
- Documentation/content/images/graph.gif +0 -0
- Documentation/content/images/login.png +0 -0
- Documentation/content/images/monitoring.png +0 -0
- Documentation/content/images/new_connection.gif +0 -0
- Documentation/content/images/simulate.gif +0 -0
- Documentation/content/images/simulate.png +0 -0
- Documentation/content/images/snmp.gif +0 -0
- Documentation/content/images/snmp.png +0 -0
- Documentation/content/images/snmp_architecture.png +0 -0
- Documentation/migrations/__init__.py +0 -0
- Documentation/models.py +9 -0
- Documentation/static/css/markdown.css +250 -0
- Documentation/templates/documentation.html +225 -0
- Documentation/templates/nav_item.html +41 -0
- Documentation/urls.py +11 -0
- Documentation/views.py +442 -0
- LogstashUI/__init__.py +0 -0
- LogstashUI/__main__.py +10 -0
- LogstashUI/asgi.py +16 -0
- LogstashUI/cli.py +626 -0
- LogstashUI/config.py +116 -0
- LogstashUI/database.py +263 -0
- LogstashUI/insecure_http.py +117 -0
- LogstashUI/logging_config.py +99 -0
- LogstashUI/migrate_engine.py +282 -0
- LogstashUI/packaging/__init__.py +3 -0
- LogstashUI/packaging/logstashui.default +68 -0
- LogstashUI/packaging/logstashui.service.in +22 -0
- LogstashUI/paths.py +181 -0
- LogstashUI/settings.py +437 -0
- LogstashUI/telemetry.py +159 -0
- LogstashUI/urls.py +56 -0
- LogstashUI/wsgi.py +77 -0
- Management/__init__.py +0 -0
- Management/apps.py +10 -0
- Management/migrations/0001_initial.py +29 -0
- Management/migrations/0002_settings.py +25 -0
- Management/migrations/0003_settings_agent_ui_url.py +29 -0
- Management/migrations/0004_settings_logstash_artifact_base_url.py +29 -0
- Management/migrations/__init__.py +0 -0
- Management/models.py +92 -0
- Management/templates/api_tokens.html +214 -0
- Management/templates/components/api_token_created.html +38 -0
- Management/templates/components/api_token_row.html +84 -0
- Management/templates/components/logstash_artifact_row.html +100 -0
- Management/templates/components/logstash_artifact_tbody.html +26 -0
- Management/templates/components/user_row.html +67 -0
- Management/templates/logs.html +98 -0
- Management/templates/logstash_artifacts.html +172 -0
- Management/templates/management.html +80 -0
- Management/templates/management_settings.html +320 -0
- Management/templates/registration/login.html +404 -0
- Management/templates/users.html +304 -0
- Management/urls.py +23 -0
- Management/views.py +804 -0
- Monitoring/__init__.py +0 -0
- Monitoring/apps.py +9 -0
- Monitoring/migrations/__init__.py +0 -0
- Monitoring/static/js/monitoring.js +463 -0
- Monitoring/templates/components/node_metrics.html +161 -0
- Monitoring/templates/components/pipeline_metrics.html +189 -0
- Monitoring/templates/monitoring.html +271 -0
- Monitoring/urls.py +16 -0
- Monitoring/views.py +724 -0
- PipelineManager/__init__.py +0 -0
- PipelineManager/agent_api.py +1173 -0
- PipelineManager/agent_client.py +59 -0
- PipelineManager/agent_modes.py +880 -0
- PipelineManager/agent_policies.py +689 -0
- PipelineManager/agent_versions.py +151 -0
- PipelineManager/apps.py +10 -0
- PipelineManager/artifact_metrics.py +171 -0
- PipelineManager/artifacts.py +820 -0
- PipelineManager/connections_crud.py +722 -0
- PipelineManager/data/default_jvm.options +76 -0
- PipelineManager/data/default_log4j2.properties +165 -0
- PipelineManager/data/default_logstash.yml +405 -0
- PipelineManager/data/plugins.json +29109 -0
- PipelineManager/editor_views.py +608 -0
- PipelineManager/forms.py +284 -0
- PipelineManager/manager_views.py +490 -0
- PipelineManager/migrations/0001_initial.py +38 -0
- PipelineManager/migrations/0002_alter_connection_connection_type_and_more.py +38 -0
- PipelineManager/migrations/0003_policy_connection_policy.py +38 -0
- PipelineManager/migrations/0004_policy_current_revision_number_and_more.py +75 -0
- PipelineManager/migrations/0005_apikey_enrollmenttoken.py +38 -0
- PipelineManager/migrations/0006_enrollmenttoken_name.py +18 -0
- PipelineManager/migrations/0007_alter_enrollmenttoken_options_and_more.py +21 -0
- PipelineManager/migrations/0008_connection_agent_id.py +18 -0
- PipelineManager/migrations/0009_connection_last_check_in_policy_jvm_options_hash_and_more.py +33 -0
- PipelineManager/migrations/0010_keystore_revision_number_pipeline_revision_number.py +23 -0
- PipelineManager/migrations/0011_keystore_kv_hash.py +18 -0
- PipelineManager/migrations/0012_policy_binary_path.py +18 -0
- PipelineManager/migrations/0013_connection_status_blob.py +18 -0
- PipelineManager/migrations/0014_pipeline_pipeline_batch_delay_and_more.py +43 -0
- PipelineManager/migrations/0015_add_pipeline_hash.py +18 -0
- PipelineManager/migrations/0016_backfill_pipeline_hash.py +32 -0
- PipelineManager/migrations/0017_policy_keystore_password.py +31 -0
- PipelineManager/migrations/0018_policy_last_deployed_at.py +18 -0
- PipelineManager/migrations/0019_connection_restart_on_next_checkin.py +18 -0
- PipelineManager/migrations/0020_pipeline_no_input_pipeline_non_reloadable.py +23 -0
- PipelineManager/migrations/0021_connection_desired_agent_version.py +18 -0
- PipelineManager/migrations/0022_keystore_managed_by_pipeline_managed_by.py +23 -0
- PipelineManager/migrations/0023_agent_modes_policy_connection.py +89 -0
- PipelineManager/migrations/0024_seed_system_policies.py +173 -0
- PipelineManager/migrations/0025_packaged_managed_policy_types.py +166 -0
- PipelineManager/migrations/0026_normalize_opt_logstash_agent_paths.py +63 -0
- PipelineManager/migrations/0027_packaged_managed_default_ports.py +49 -0
- PipelineManager/migrations/0028_apikey_admin_tokens.py +80 -0
- PipelineManager/migrations/0029_logstash_artifacts.py +45 -0
- PipelineManager/migrations/0030_connection_allow_self_signed_certs.py +33 -0
- PipelineManager/migrations/0031_deploy_system_policies.py +93 -0
- PipelineManager/migrations/0032_connection_agent_inbound_key.py +30 -0
- PipelineManager/migrations/0033_simulation_result.py +26 -0
- PipelineManager/migrations/__init__.py +0 -0
- PipelineManager/models.py +1300 -0
- PipelineManager/pipelines_crud.py +738 -0
- PipelineManager/policies_crud.py +772 -0
- PipelineManager/sim_keystore.py +319 -0
- PipelineManager/simulation.py +1581 -0
- PipelineManager/static/css/codemirror.min.css +1 -0
- PipelineManager/static/css/graph_move.css +79 -0
- PipelineManager/static/css/monokai.min.css +1 -0
- PipelineManager/static/css/move_mode.css +144 -0
- PipelineManager/static/css/show-hint.min.css +1 -0
- PipelineManager/static/images/age.png +0 -0
- PipelineManager/static/images/aggregate.png +0 -0
- PipelineManager/static/images/alter.png +0 -0
- PipelineManager/static/images/azure_event_hubs.png +0 -0
- PipelineManager/static/images/beats.png +0 -0
- PipelineManager/static/images/boundary.png +0 -0
- PipelineManager/static/images/bytes.png +0 -0
- PipelineManager/static/images/cidr.png +0 -0
- PipelineManager/static/images/cipher.png +0 -0
- PipelineManager/static/images/circonus.png +0 -0
- PipelineManager/static/images/clone.png +0 -0
- PipelineManager/static/images/cloudwatch.png +0 -0
- PipelineManager/static/images/comment.png +0 -0
- PipelineManager/static/images/continue.png +0 -0
- PipelineManager/static/images/couchdb_changes.png +0 -0
- PipelineManager/static/images/csv.png +0 -0
- PipelineManager/static/images/datadog.png +0 -0
- PipelineManager/static/images/datadog_metrics.png +0 -0
- PipelineManager/static/images/date.png +0 -0
- PipelineManager/static/images/de_dot.png +0 -0
- PipelineManager/static/images/dead_letter_queue.png +0 -0
- PipelineManager/static/images/dissect.png +0 -0
- PipelineManager/static/images/dns.png +0 -0
- PipelineManager/static/images/drop.png +0 -0
- PipelineManager/static/images/dynatrace.png +0 -0
- PipelineManager/static/images/elapsed.png +0 -0
- PipelineManager/static/images/elastic_agent.png +0 -0
- PipelineManager/static/images/elastic_integration.png +0 -0
- PipelineManager/static/images/elastic_serverless_forwarder.png +0 -0
- PipelineManager/static/images/elastic_workplace_search.png +0 -0
- PipelineManager/static/images/elasticsearch.png +0 -0
- PipelineManager/static/images/else.png +0 -0
- PipelineManager/static/images/else_if.png +0 -0
- PipelineManager/static/images/email.png +0 -0
- PipelineManager/static/images/environment.png +0 -0
- PipelineManager/static/images/exec.png +0 -0
- PipelineManager/static/images/extractnumbers.png +0 -0
- PipelineManager/static/images/file.png +0 -0
- PipelineManager/static/images/fingerprint.png +0 -0
- PipelineManager/static/images/ganglia.png +0 -0
- PipelineManager/static/images/gelf.png +0 -0
- PipelineManager/static/images/generator.png +0 -0
- PipelineManager/static/images/geoip.png +0 -0
- PipelineManager/static/images/github.png +0 -0
- PipelineManager/static/images/google_bigquery.png +0 -0
- PipelineManager/static/images/google_cloud_storage.png +0 -0
- PipelineManager/static/images/google_pubsub.png +0 -0
- PipelineManager/static/images/graphite.png +0 -0
- PipelineManager/static/images/graphtastic.png +0 -0
- PipelineManager/static/images/grok.png +0 -0
- PipelineManager/static/images/heartbeat.png +0 -0
- PipelineManager/static/images/http.png +0 -0
- PipelineManager/static/images/http_poller.png +0 -0
- PipelineManager/static/images/i18n.png +0 -0
- PipelineManager/static/images/if.png +0 -0
- PipelineManager/static/images/imap.png +0 -0
- PipelineManager/static/images/influxdb.png +0 -0
- PipelineManager/static/images/irc.png +0 -0
- PipelineManager/static/images/java_generator.png +0 -0
- PipelineManager/static/images/java_stdin.png +0 -0
- PipelineManager/static/images/java_stdout.png +0 -0
- PipelineManager/static/images/java_uuid.png +0 -0
- PipelineManager/static/images/jdbc.png +0 -0
- PipelineManager/static/images/jdbc_static.png +0 -0
- PipelineManager/static/images/jdbc_streaming.png +0 -0
- PipelineManager/static/images/jms.png +0 -0
- PipelineManager/static/images/jmx.png +0 -0
- PipelineManager/static/images/json.png +0 -0
- PipelineManager/static/images/json_encode.png +0 -0
- PipelineManager/static/images/juggernaut.png +0 -0
- PipelineManager/static/images/kafka.png +0 -0
- PipelineManager/static/images/kinesis.png +0 -0
- PipelineManager/static/images/kv.png +0 -0
- PipelineManager/static/images/librato.png +0 -0
- PipelineManager/static/images/log4j.png +0 -0
- PipelineManager/static/images/loggly.png +0 -0
- PipelineManager/static/images/logstash.png +0 -0
- PipelineManager/static/images/lumberjack.png +0 -0
- PipelineManager/static/images/meetup.png +0 -0
- PipelineManager/static/images/memcached.png +0 -0
- PipelineManager/static/images/metriccatcher.png +0 -0
- PipelineManager/static/images/metricize.png +0 -0
- PipelineManager/static/images/metrics.png +0 -0
- PipelineManager/static/images/mongodb.png +0 -0
- PipelineManager/static/images/mutate.png +0 -0
- PipelineManager/static/images/nagios.png +0 -0
- PipelineManager/static/images/nagios_nsca.png +0 -0
- PipelineManager/static/images/opentsdb.png +0 -0
- PipelineManager/static/images/pagerduty.png +0 -0
- PipelineManager/static/images/pipe.png +0 -0
- PipelineManager/static/images/pipeline.png +0 -0
- PipelineManager/static/images/prune.png +0 -0
- PipelineManager/static/images/puppet_facter.png +0 -0
- PipelineManager/static/images/rabbitmq.png +0 -0
- PipelineManager/static/images/range.png +0 -0
- PipelineManager/static/images/redis.png +0 -0
- PipelineManager/static/images/redmine.png +0 -0
- PipelineManager/static/images/relp.png +0 -0
- PipelineManager/static/images/riak.png +0 -0
- PipelineManager/static/images/riemann.png +0 -0
- PipelineManager/static/images/rss.png +0 -0
- PipelineManager/static/images/ruby.png +0 -0
- PipelineManager/static/images/s3-sns-sqs.png +0 -0
- PipelineManager/static/images/s3.png +0 -0
- PipelineManager/static/images/salesforce.png +0 -0
- PipelineManager/static/images/sink.png +0 -0
- PipelineManager/static/images/sleep.png +0 -0
- PipelineManager/static/images/snmp.png +0 -0
- PipelineManager/static/images/snmptrap.png +0 -0
- PipelineManager/static/images/sns.png +0 -0
- PipelineManager/static/images/solr_http.png +0 -0
- PipelineManager/static/images/split.png +0 -0
- PipelineManager/static/images/sqlite.png +0 -0
- PipelineManager/static/images/sqs.png +0 -0
- PipelineManager/static/images/statsd.png +0 -0
- PipelineManager/static/images/stdin.png +0 -0
- PipelineManager/static/images/stdout.png +0 -0
- PipelineManager/static/images/stomp.png +0 -0
- PipelineManager/static/images/syslog.png +0 -0
- PipelineManager/static/images/syslog_pri.png +0 -0
- PipelineManager/static/images/tcp.png +0 -0
- PipelineManager/static/images/threats_classifier.png +0 -0
- PipelineManager/static/images/throttle.png +0 -0
- PipelineManager/static/images/timber.png +0 -0
- PipelineManager/static/images/tld.png +0 -0
- PipelineManager/static/images/translate.png +0 -0
- PipelineManager/static/images/truncate.png +0 -0
- PipelineManager/static/images/twitter.png +0 -0
- PipelineManager/static/images/udp.png +0 -0
- PipelineManager/static/images/unix.png +0 -0
- PipelineManager/static/images/urldecode.png +0 -0
- PipelineManager/static/images/useragent.png +0 -0
- PipelineManager/static/images/uuid.png +0 -0
- PipelineManager/static/images/varnishlog.png +0 -0
- PipelineManager/static/images/webhdfs.png +0 -0
- PipelineManager/static/images/websocket.png +0 -0
- PipelineManager/static/images/wmi.png +0 -0
- PipelineManager/static/images/wurfl_device_detection.png +0 -0
- PipelineManager/static/images/xml.png +0 -0
- PipelineManager/static/images/xmpp.png +0 -0
- PipelineManager/static/images/zabbix.png +0 -0
- PipelineManager/static/js/agent_inspect_modal.js +141 -0
- PipelineManager/static/js/agent_policies.js +3746 -0
- PipelineManager/static/js/agent_status_sse.js +166 -0
- PipelineManager/static/js/codemirror.min.js +1 -0
- PipelineManager/static/js/connections_table.js +551 -0
- PipelineManager/static/js/d3.v7.js +20625 -0
- PipelineManager/static/js/diff_modal.js +995 -0
- PipelineManager/static/js/expression_editor.js +291 -0
- PipelineManager/static/js/js-yaml.min.js +1 -0
- PipelineManager/static/js/logstashyml_guides.js +1063 -0
- PipelineManager/static/js/move_graph.js +577 -0
- PipelineManager/static/js/move_mode.js +559 -0
- PipelineManager/static/js/pipeline_editor.js +4102 -0
- PipelineManager/static/js/pipeline_graph_editor.js +3542 -0
- PipelineManager/static/js/pipeline_list.js +274 -0
- PipelineManager/static/js/pipeline_settings.js +121 -0
- PipelineManager/static/js/pipeline_text_editor.js +2088 -0
- PipelineManager/static/js/plugin_config_modal.js +2827 -0
- PipelineManager/static/js/policy_deploy_modal.js +1066 -0
- PipelineManager/static/js/show-hint.min.js +1 -0
- PipelineManager/static/js/sim_targets.js +380 -0
- PipelineManager/static/js/simple-comment-mode.js +56 -0
- PipelineManager/static/js/simulation_modal.js +1135 -0
- PipelineManager/static/js/simulation_results.js +2778 -0
- PipelineManager/static/js/stats_strip.js +231 -0
- PipelineManager/static/js/yaml.js +120 -0
- PipelineManager/system_policy_defaults.py +279 -0
- PipelineManager/templates/components/pipeline_editor/diff_modal.html +127 -0
- PipelineManager/templates/components/pipeline_editor/expression_editor.html +160 -0
- PipelineManager/templates/components/pipeline_editor/plugin_config_modal.html +119 -0
- PipelineManager/templates/components/pipeline_editor/plugin_modal.html +1016 -0
- PipelineManager/templates/components/pipeline_editor/simulation_modal.html +394 -0
- PipelineManager/templates/components/pipeline_editor/simulation_results.html +123 -0
- PipelineManager/templates/components/pipeline_editor/stats_strip.html +123 -0
- PipelineManager/templates/components/pipeline_editor/view_code_modal.html +133 -0
- PipelineManager/templates/components/pipeline_manager/agent_inspect_content.html +805 -0
- PipelineManager/templates/components/pipeline_manager/agent_inspect_modal.html +40 -0
- PipelineManager/templates/components/pipeline_manager/agent_policies.html +2421 -0
- PipelineManager/templates/components/pipeline_manager/change_policy_modal.html +210 -0
- PipelineManager/templates/components/pipeline_manager/collapsible_row.html +11 -0
- PipelineManager/templates/components/pipeline_manager/connection_modal.html +1361 -0
- PipelineManager/templates/components/pipeline_manager/keystore_modal.html +269 -0
- PipelineManager/templates/components/pipeline_manager/logstashyml_guides/centralized_pipeline_management.html +291 -0
- PipelineManager/templates/components/pipeline_manager/logstashyml_guides/default.html +166 -0
- PipelineManager/templates/components/pipeline_manager/mcp_modal.html +241 -0
- PipelineManager/templates/components/pipeline_manager/pipeline_list_content.html +586 -0
- PipelineManager/templates/components/pipeline_manager/policy_deploy_modal.html +238 -0
- PipelineManager/templates/pipeline_editor.html +1738 -0
- PipelineManager/templates/pipeline_graph_editor.html +99 -0
- PipelineManager/templates/pipeline_manager.html +584 -0
- PipelineManager/templates/pipeline_text_editor.html +350 -0
- PipelineManager/urls.py +99 -0
- SNMP/__init__.py +0 -0
- SNMP/ai_template_generation.py +232 -0
- SNMP/apps.py +9 -0
- SNMP/assets/device_template_generation/agents/snmp-profile-author.json +15 -0
- SNMP/assets/device_template_generation/skills/snmp-catalog.json +9 -0
- SNMP/data/authoring_instructions.md +65 -0
- SNMP/data/grounding/.gitignore +4 -0
- SNMP/data/grounding/build_grounding.py +35 -0
- SNMP/data/grounding/grounding.json +1 -0
- SNMP/data/grounding/sample_agent_payload.cisco2960x.json +2184 -0
- SNMP/data/mib_reference/std_bgp4_mib.json +43 -0
- SNMP/data/mib_reference/std_entity_sensors.json +28 -0
- SNMP/data/mib_reference/std_host_resources.json +32 -0
- SNMP/data/mib_reference/std_ospf_mib.json +55 -0
- SNMP/data/mib_reference/std_ucd_linux.json +27 -0
- SNMP/data/normalizers.json +103 -0
- SNMP/data/official_device_templates/arista_eos.json +24 -0
- SNMP/data/official_device_templates/aruba_wireless_controller.json +23 -0
- SNMP/data/official_device_templates/brocade_fc_switch.json +20 -0
- SNMP/data/official_device_templates/cisco_ios.json +21 -0
- SNMP/data/official_device_templates/default.json +13 -0
- SNMP/data/official_device_templates/dell_idrac.json +22 -0
- SNMP/data/official_device_templates/dell_x1026.json +16 -0
- SNMP/data/official_device_templates/dlink_dgs1210_switch.json +19 -0
- SNMP/data/official_device_templates/eastpower_ups.json +20 -0
- SNMP/data/official_device_templates/eaton_ups.json +22 -0
- SNMP/data/official_device_templates/epson_printer.json +18 -0
- SNMP/data/official_device_templates/geist_watchdog.json +20 -0
- SNMP/data/official_device_templates/generic_linux.json +18 -0
- SNMP/data/official_device_templates/generic_ont.json +18 -0
- SNMP/data/official_device_templates/generic_ups.json +16 -0
- SNMP/data/official_device_templates/hp_laserjet_mfp_m281cdw.json +18 -0
- SNMP/data/official_device_templates/hpe_nimble.json +17 -0
- SNMP/data/official_device_templates/huawei_ups.json +19 -0
- SNMP/data/official_device_templates/ingrasys_ups.json +19 -0
- SNMP/data/official_device_templates/isilon_onefs.json +22 -0
- SNMP/data/official_device_templates/mellanox_sx6036.json +20 -0
- SNMP/data/official_device_templates/netapp_7mode.json +22 -0
- SNMP/data/official_device_templates/palo_alto_firewall.json +21 -0
- SNMP/data/official_device_templates/phoenixtec_ups.json +18 -0
- SNMP/data/official_device_templates/ubiquiti_unifi_ap.json +19 -0
- SNMP/data/official_device_templates/ubiquiti_unifi_switch.json +18 -0
- SNMP/data/official_device_templates/ubiquiti_unifi_udm.json +19 -0
- SNMP/data/official_device_templates/versa_flexvnf_appliance.json +19 -0
- SNMP/data/official_profiles/arista_eos.json +16 -0
- SNMP/data/official_profiles/aruba_wireless_controller.json +145 -0
- SNMP/data/official_profiles/brocade_fibre_channel_switch_fibre_channel_ports.json +35 -0
- SNMP/data/official_profiles/brocade_fibre_channel_switch_name_server.json +23 -0
- SNMP/data/official_profiles/brocade_fibre_channel_switch_system_metrics.json +36 -0
- SNMP/data/official_profiles/cisco_cdp.json +26 -0
- SNMP/data/official_profiles/cisco_fans.json +18 -0
- SNMP/data/official_profiles/cisco_sensors.json +21 -0
- SNMP/data/official_profiles/cisco_system_metrics.json +40 -0
- SNMP/data/official_profiles/dell_idrac_cpu.json +19 -0
- SNMP/data/official_profiles/dell_idrac_fans.json +20 -0
- SNMP/data/official_profiles/dell_idrac_global_status.json +13 -0
- SNMP/data/official_profiles/dell_idrac_memory.json +20 -0
- SNMP/data/official_profiles/dell_idrac_power_supply.json +19 -0
- SNMP/data/official_profiles/dell_idrac_raid_controller.json +19 -0
- SNMP/data/official_profiles/dlink_dgs1210.json +15 -0
- SNMP/data/official_profiles/dlink_dgs1210_system_metrics.json +38 -0
- SNMP/data/official_profiles/eaton_ups.json +40 -0
- SNMP/data/official_profiles/geist_environment.json +50 -0
- SNMP/data/official_profiles/generic_arp.json +19 -0
- SNMP/data/official_profiles/generic_bgp.json +24 -0
- SNMP/data/official_profiles/generic_entity_psu.json +26 -0
- SNMP/data/official_profiles/generic_entity_sensor.json +22 -0
- SNMP/data/official_profiles/generic_host_system_metrics.json +68 -0
- SNMP/data/official_profiles/generic_interfaces.json +86 -0
- SNMP/data/official_profiles/generic_ip_addr.json +19 -0
- SNMP/data/official_profiles/generic_lldp.json +54 -0
- SNMP/data/official_profiles/generic_lm_sensors.json +37 -0
- SNMP/data/official_profiles/generic_mac_table.json +19 -0
- SNMP/data/official_profiles/generic_ont.json +88 -0
- SNMP/data/official_profiles/generic_ospf.json +21 -0
- SNMP/data/official_profiles/generic_printer_mib.json +48 -0
- SNMP/data/official_profiles/generic_rmon.json +38 -0
- SNMP/data/official_profiles/generic_system.json +17 -0
- SNMP/data/official_profiles/generic_ucd_system_metrics.json +63 -0
- SNMP/data/official_profiles/generic_ups_mib.json +154 -0
- SNMP/data/official_profiles/hpe_nimble_volumes.json +59 -0
- SNMP/data/official_profiles/huawei_ups.json +111 -0
- SNMP/data/official_profiles/isilon_performance.json +92 -0
- SNMP/data/official_profiles/isilon_protocols.json +77 -0
- SNMP/data/official_profiles/isilon_system.json +86 -0
- SNMP/data/official_profiles/mellanox_mlnx_os.json +15 -0
- SNMP/data/official_profiles/netapp_7mode_data_protection.json +106 -0
- SNMP/data/official_profiles/netapp_7mode_disks.json +51 -0
- SNMP/data/official_profiles/netapp_7mode_protocols.json +66 -0
- SNMP/data/official_profiles/netapp_7mode_system.json +92 -0
- SNMP/data/official_profiles/netapp_7mode_volumes.json +166 -0
- SNMP/data/official_profiles/paloalto_components.json +36 -0
- SNMP/data/official_profiles/paloalto_system.json +15 -0
- SNMP/data/official_profiles/traps.json +16 -0
- SNMP/data/official_profiles/ubiquiti_unifi_switch.json +18 -0
- SNMP/data/official_profiles/ubiquiti_unifi_switch_system.json +14 -0
- SNMP/data/official_profiles/ubiquiti_unifi_wireless.json +60 -0
- SNMP/data/official_profiles/versa_flexvnf.json +14 -0
- SNMP/data/schema.md +650 -0
- SNMP/data/schema_reference/snmp_field_schema.md +747 -0
- SNMP/data/snmp_template.json +629 -0
- SNMP/data/template_profile_context.md +3986 -0
- SNMP/inline_grounding.py +77 -0
- SNMP/management/__init__.py +1 -0
- SNMP/management/commands/__init__.py +1 -0
- SNMP/management/commands/generate_template_profile_context.py +272 -0
- SNMP/management/commands/load_test_snmp_data.py +240 -0
- SNMP/management/commands/sync_snmp_official_data.py +263 -0
- SNMP/management/commands/unload_test_snmp_data.py +77 -0
- SNMP/migrations/0001_initial.py +101 -0
- SNMP/migrations/0002_devicetemplate.py +34 -0
- SNMP/migrations/0003_remove_devicetemplate_type_remove_profile_type_and_more.py +31 -0
- SNMP/migrations/0004_device_device_template.py +19 -0
- SNMP/migrations/0005_devicetemplate_product_profile_product.py +23 -0
- SNMP/migrations/0006_alter_devicetemplate_model_and_more.py +28 -0
- SNMP/migrations/0007_remove_device_profiles.py +17 -0
- SNMP/migrations/0008_devicetemplate_type.py +18 -0
- SNMP/migrations/0009_alter_device_device_template.py +19 -0
- SNMP/migrations/0010_alter_device_device_template.py +19 -0
- SNMP/migrations/0011_network_namespace.py +18 -0
- SNMP/migrations/0012_profile_normalizers.py +18 -0
- SNMP/migrations/0013_snmpdeploymentstate.py +26 -0
- SNMP/migrations/0014_alter_snmpdeploymentstate_last_config_change.py +18 -0
- SNMP/migrations/0015_alter_snmpdeploymentstate_last_config_change.py +20 -0
- SNMP/migrations/0016_alter_snmpdeploymentstate_last_config_change.py +18 -0
- SNMP/migrations/0017_remove_network_logstash_name.py +17 -0
- SNMP/migrations/0018_add_official_key.py +39 -0
- SNMP/migrations/0019_network_namespace_from_device_template.py +18 -0
- SNMP/migrations/0020_device_hostname_alter_device_ip_address_and_more.py +27 -0
- SNMP/migrations/0021_device_building_device_latitude_device_longitude_and_more.py +43 -0
- SNMP/migrations/0022_alter_device_latitude_alter_device_longitude.py +23 -0
- SNMP/migrations/0023_network_agent_connection_network_deployment_mode_and_more.py +30 -0
- SNMP/migrations/0024_network_credential_mode.py +18 -0
- SNMP/migrations/0025_network_ssl_certificate_authorities.py +18 -0
- SNMP/migrations/__init__.py +0 -0
- SNMP/models.py +892 -0
- SNMP/network_map.py +660 -0
- SNMP/overview.py +394 -0
- SNMP/snmp_crud.py +6082 -0
- SNMP/snmp_grounding.py +146 -0
- SNMP/snmp_normalizers.py +594 -0
- SNMP/snmp_pipeline_generator.py +1658 -0
- SNMP/snmp_test.py +962 -0
- SNMP/static/css/snmp.css +33 -0
- SNMP/static/images/apc.png +0 -0
- SNMP/static/images/arista.png +0 -0
- SNMP/static/images/aruba.png +0 -0
- SNMP/static/images/brocade.png +0 -0
- SNMP/static/images/cisco.png +0 -0
- SNMP/static/images/dell.png +0 -0
- SNMP/static/images/dlink.png +0 -0
- SNMP/static/images/east.png +0 -0
- SNMP/static/images/eaton.png +0 -0
- SNMP/static/images/epson.png +0 -0
- SNMP/static/images/hauwei.png +0 -0
- SNMP/static/images/hp.png +0 -0
- SNMP/static/images/hpe.png +0 -0
- SNMP/static/images/ingrasys.png +0 -0
- SNMP/static/images/linux.png +0 -0
- SNMP/static/images/mellanox.png +0 -0
- SNMP/static/images/netapp.png +0 -0
- SNMP/static/images/paloalto.png +0 -0
- SNMP/static/images/phoenixtec.png +0 -0
- SNMP/static/images/ubiquiti.png +0 -0
- SNMP/static/images/unknown.png +0 -0
- SNMP/static/images/versa.png +0 -0
- SNMP/static/images/vertiv.png +0 -0
- SNMP/static/js/ai_device_template_modal.js +1116 -0
- SNMP/static/js/credentials_table.js +291 -0
- SNMP/static/js/devices_table.js +588 -0
- SNMP/static/js/discovered_devices.js +291 -0
- SNMP/static/js/network_map.js +1657 -0
- SNMP/static/js/networks_table.js +360 -0
- SNMP/static/js/onboarding.js +866 -0
- SNMP/static/js/overview.js +416 -0
- SNMP/static/js/snmp_changes_indicator.js +76 -0
- SNMP/static/js/snmp_commit_modal.js +39 -0
- SNMP/static/js/snmp_credentials_modal.js +217 -0
- SNMP/static/js/snmp_device_template_modal.js +669 -0
- SNMP/static/js/snmp_device_visual_preview.js +1707 -0
- SNMP/static/js/snmp_devices_modal.js +912 -0
- SNMP/static/js/snmp_diff_modal.js +1559 -0
- SNMP/static/js/snmp_network_modal.js +940 -0
- SNMP/static/js/snmp_profile_modal.js +1212 -0
- SNMP/static/js/snmp_profile_modal_helpers.js +17 -0
- SNMP/static/js/snmp_test.js +538 -0
- SNMP/templates/Credentials.html +325 -0
- SNMP/templates/DeviceTemplates.html +1059 -0
- SNMP/templates/Devices.html +274 -0
- SNMP/templates/Networks.html +469 -0
- SNMP/templates/Onboarding.html +521 -0
- SNMP/templates/Overview.html +227 -0
- SNMP/templates/components/ai_device_template_modal.html +46 -0
- SNMP/templates/components/ai_generate_template_content.html +224 -0
- SNMP/templates/components/device_template_profile_modal.html +60 -0
- SNMP/templates/components/discovered_devices_content.html +86 -0
- SNMP/templates/components/discovered_devices_modal.html +43 -0
- SNMP/templates/components/gmaps_latlon_modal.html +93 -0
- SNMP/templates/components/network_map.html +110 -0
- SNMP/templates/components/snmp_commit_modal.html +53 -0
- SNMP/templates/components/snmp_credentials_modal.html +189 -0
- SNMP/templates/components/snmp_device_modal.html +6 -0
- SNMP/templates/components/snmp_device_template_modal.html +129 -0
- SNMP/templates/components/snmp_device_visual_preview.html +347 -0
- SNMP/templates/components/snmp_devices_modal.html +330 -0
- SNMP/templates/components/snmp_diff_modal.html +148 -0
- SNMP/templates/components/snmp_network_modal.html +380 -0
- SNMP/templates/components/snmp_profile_modal.html +147 -0
- SNMP/templates/components/snmp_test_modal.html +398 -0
- SNMP/templatetags/__init__.py +0 -0
- SNMP/templatetags/snmp_extras.py +17 -0
- SNMP/urls.py +94 -0
- SNMP/views.py +913 -0
- Site/__init__.py +0 -0
- Site/apps.py +9 -0
- Site/migrations/__init__.py +0 -0
- Site/product_ca_views.py +41 -0
- Site/static/images/ElasticIcon.png +0 -0
- Site/static/images/LoggyIcon.png +0 -0
- Site/static/images/LoggyWizardIcon.png +0 -0
- Site/static/images/LogstashAgentIcon.png +0 -0
- Site/static/images/LogstashIcon.png +0 -0
- Site/static/js/base.js +192 -0
- Site/static/js/marked.min.js +69 -0
- Site/templates/base.html +52 -0
- Site/templates/error.html +65 -0
- Site/templates/home.html +148 -0
- Site/templates/navigation.html +530 -0
- Site/templates/popup.html +251 -0
- Site/templatetags/__init__.py +0 -0
- Site/templatetags/custom_filters.py +36 -0
- Site/urls.py +21 -0
- Site/views.py +200 -0
- Utilities/__init__.py +0 -0
- Utilities/apps.py +9 -0
- Utilities/data/grok-patterns/LICENSE +202 -0
- Utilities/data/grok-patterns/ecs-v1/aws +33 -0
- Utilities/data/grok-patterns/ecs-v1/bacula +53 -0
- Utilities/data/grok-patterns/ecs-v1/bind +13 -0
- Utilities/data/grok-patterns/ecs-v1/bro +30 -0
- Utilities/data/grok-patterns/ecs-v1/exim +26 -0
- Utilities/data/grok-patterns/ecs-v1/firewalls +111 -0
- Utilities/data/grok-patterns/ecs-v1/grok-patterns +95 -0
- Utilities/data/grok-patterns/ecs-v1/haproxy +40 -0
- Utilities/data/grok-patterns/ecs-v1/httpd +17 -0
- Utilities/data/grok-patterns/ecs-v1/java +34 -0
- Utilities/data/grok-patterns/ecs-v1/junos +13 -0
- Utilities/data/grok-patterns/ecs-v1/linux-syslog +16 -0
- Utilities/data/grok-patterns/ecs-v1/maven +1 -0
- Utilities/data/grok-patterns/ecs-v1/mcollective +4 -0
- Utilities/data/grok-patterns/ecs-v1/mongodb +7 -0
- Utilities/data/grok-patterns/ecs-v1/nagios +124 -0
- Utilities/data/grok-patterns/ecs-v1/postgresql +2 -0
- Utilities/data/grok-patterns/ecs-v1/rails +13 -0
- Utilities/data/grok-patterns/ecs-v1/redis +3 -0
- Utilities/data/grok-patterns/ecs-v1/ruby +2 -0
- Utilities/data/grok-patterns/ecs-v1/squid +6 -0
- Utilities/data/grok-patterns/ecs-v1/zeek +33 -0
- Utilities/data/grok-patterns/legacy/aws +14 -0
- Utilities/data/grok-patterns/legacy/bacula +50 -0
- Utilities/data/grok-patterns/legacy/bind +3 -0
- Utilities/data/grok-patterns/legacy/bro +13 -0
- Utilities/data/grok-patterns/legacy/exim +19 -0
- Utilities/data/grok-patterns/legacy/firewalls +91 -0
- Utilities/data/grok-patterns/legacy/grok-patterns +95 -0
- Utilities/data/grok-patterns/legacy/haproxy +39 -0
- Utilities/data/grok-patterns/legacy/httpd +15 -0
- Utilities/data/grok-patterns/legacy/java +17 -0
- Utilities/data/grok-patterns/legacy/junos +9 -0
- Utilities/data/grok-patterns/legacy/linux-syslog +16 -0
- Utilities/data/grok-patterns/legacy/maven +1 -0
- Utilities/data/grok-patterns/legacy/mcollective +1 -0
- Utilities/data/grok-patterns/legacy/mcollective-patterns +4 -0
- Utilities/data/grok-patterns/legacy/mongodb +7 -0
- Utilities/data/grok-patterns/legacy/nagios +124 -0
- Utilities/data/grok-patterns/legacy/postgresql +3 -0
- Utilities/data/grok-patterns/legacy/rails +13 -0
- Utilities/data/grok-patterns/legacy/redis +3 -0
- Utilities/data/grok-patterns/legacy/ruby +2 -0
- Utilities/data/grok-patterns/legacy/squid +4 -0
- Utilities/dissect.py +302 -0
- Utilities/grok.py +412 -0
- Utilities/migrations/__init__.py +0 -0
- Utilities/static/css/debugger_editor.css +88 -0
- Utilities/static/js/debugger_editor.js +93 -0
- Utilities/static/js/grok_debugger.js +131 -0
- Utilities/templates/dissect_debugger.html +95 -0
- Utilities/templates/grok_debugger.html +99 -0
- Utilities/urls.py +14 -0
- Utilities/views.py +363 -0
- logstashui-0.5.5.dev0.dist-info/METADATA +333 -0
- logstashui-0.5.5.dev0.dist-info/RECORD +762 -0
- logstashui-0.5.5.dev0.dist-info/WHEEL +4 -0
- logstashui-0.5.5.dev0.dist-info/entry_points.txt +2 -0
- logstashui-0.5.5.dev0.dist-info/licenses/LICENSE.txt +93 -0
- logstashui-0.5.5.dev0.dist-info/licenses/NOTICE.txt +2772 -0
- theme/__init__.py +0 -0
- theme/apps.py +9 -0
- theme/package-lock.json +6 -0
- theme/static/css/dist/styles.css +2 -0
- theme/static/images/favicon.ico +0 -0
- theme/static_src/.gitignore +1 -0
- theme/static_src/package-lock.json +1930 -0
- theme/static_src/package.json +26 -0
- theme/static_src/postcss.config.js +7 -0
- theme/static_src/src/styles.css +38 -0
- theme/static_src/tailwind.config.js +43 -0
- theme/templates/base.html +32 -0
|
@@ -0,0 +1,1361 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
3
|
+
* or more contributor license agreements. Licensed under the Elastic License;
|
|
4
|
+
* you may not use this file except in compliance with the Elastic License.
|
|
5
|
+
-->
|
|
6
|
+
|
|
7
|
+
<!-- Connection Form Flyout -->
|
|
8
|
+
<div id="connectionFormFlyout" class="hidden fixed inset-0 overflow-hidden" style="z-index: 80;" data-confirm-close>
|
|
9
|
+
<div class="absolute inset-0 bg-black/30 backdrop-blur-sm" onclick="safeClose(closeFlyout)"></div>
|
|
10
|
+
<div class="absolute inset-y-0 right-0 max-w-full flex">
|
|
11
|
+
<div class="w-[32rem] bg-base-200 shadow-xl flex flex-col h-full">
|
|
12
|
+
<div class="flex justify-between items-center p-6 border-b border-base-300">
|
|
13
|
+
<h2 id="connectionModalTitle" class="text-xl font-bold">Add New Connection</h2>
|
|
14
|
+
<button onclick="closeFlyout()" class="btn btn-ghost btn-sm btn-circle">
|
|
15
|
+
<svg class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
16
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
|
17
|
+
</svg>
|
|
18
|
+
</button>
|
|
19
|
+
</div>
|
|
20
|
+
<div class="flex-1 overflow-y-auto p-6">
|
|
21
|
+
<!-- Error message container -->
|
|
22
|
+
<div id="connectionErrorContainer"></div>
|
|
23
|
+
|
|
24
|
+
<form id="connectionForm"
|
|
25
|
+
hx-post="/ConnectionManager/AddConnection"
|
|
26
|
+
hx-swap="none"
|
|
27
|
+
hx-indicator=".loading"
|
|
28
|
+
hx-on::before-request="document.getElementById('connectionErrorContainer').innerHTML = '';"
|
|
29
|
+
hx-on::after-request="
|
|
30
|
+
const errorContainer = document.getElementById('connectionErrorContainer');
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
const response = JSON.parse(event.detail.xhr.responseText);
|
|
34
|
+
|
|
35
|
+
if (response.success) {
|
|
36
|
+
// Store the connection ID so closeFlyout() triggers a page reload
|
|
37
|
+
window.lastCreatedConnectionId = response.connection_id;
|
|
38
|
+
|
|
39
|
+
const isEdit = window.connectionEditMode === 'edit';
|
|
40
|
+
showToast(response.message || (isEdit ? 'Connection updated successfully!' : 'Connection created and tested successfully!'), 'success');
|
|
41
|
+
|
|
42
|
+
// Close the modal (page reload is handled by the closeFlyout override in pipeline_manager.html)
|
|
43
|
+
closeFlyout();
|
|
44
|
+
|
|
45
|
+
// Clear the form
|
|
46
|
+
document.getElementById('connectionForm').reset();
|
|
47
|
+
errorContainer.innerHTML = '';
|
|
48
|
+
} else {
|
|
49
|
+
// Display error message
|
|
50
|
+
errorContainer.innerHTML = `
|
|
51
|
+
<div class='p-4 mb-4 text-red-700 bg-red-100 border border-red-300 rounded-lg'>
|
|
52
|
+
<h3 class='font-bold mb-2 text-lg'>❌ Connection Test Failed</h3>
|
|
53
|
+
<p class='mb-3'>The connection could not be established. Please check your credentials and try again.</p>
|
|
54
|
+
<div class='mt-3 p-3 bg-red-50 border border-red-200 rounded'>
|
|
55
|
+
<p class='font-semibold mb-1 text-sm'>Error Details:</p>
|
|
56
|
+
<pre class='text-xs overflow-auto whitespace-pre-wrap break-words max-h-64'>${response.error || 'Unknown error'}</pre>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
`;
|
|
60
|
+
showToast('Connection test failed - check the error message above', 'error');
|
|
61
|
+
errorContainer.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
62
|
+
}
|
|
63
|
+
} catch (e) {
|
|
64
|
+
console.error('Error parsing response:', e);
|
|
65
|
+
errorContainer.innerHTML = `
|
|
66
|
+
<div class='p-4 mb-4 text-red-700 bg-red-100 border border-red-300 rounded-lg'>
|
|
67
|
+
<h3 class='font-bold mb-2'>Error</h3>
|
|
68
|
+
<p>Failed to process server response. Please try again.</p>
|
|
69
|
+
</div>
|
|
70
|
+
`;
|
|
71
|
+
showToast('Failed to process server response', 'error');
|
|
72
|
+
}
|
|
73
|
+
">
|
|
74
|
+
{% csrf_token %}
|
|
75
|
+
|
|
76
|
+
<!-- Hidden connection type field -->
|
|
77
|
+
<input type="hidden" name="connection_type" id="connectionTypeField" value="CENTRALIZED">
|
|
78
|
+
|
|
79
|
+
<!-- Credential re-entry notice (edit mode only) -->
|
|
80
|
+
<div id="credentialReentryHint" class="hidden p-3 mb-4 bg-amber-900/20 border border-amber-600/40 rounded-lg">
|
|
81
|
+
<div class="flex items-start gap-2">
|
|
82
|
+
<svg class="w-4 h-4 text-amber-400 flex-shrink-0 mt-0.5" fill="currentColor" viewBox="0 0 20 20">
|
|
83
|
+
<path fill-rule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clip-rule="evenodd"/>
|
|
84
|
+
</svg>
|
|
85
|
+
<p class="text-amber-300 text-sm">You must re-enter your credentials to save changes. They are tested against the cluster before the update is applied.</p>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
<!-- Connection Name Field (only for centralized connections) -->
|
|
90
|
+
<div id="connectionNameField" class="mb-6">
|
|
91
|
+
<label for="{{ form.name.id_for_label }}" class="block text-sm font-medium text-gray-300 mb-2">
|
|
92
|
+
Connection Name <span class="text-red-500">*</span>
|
|
93
|
+
</label>
|
|
94
|
+
{{ form.name }}
|
|
95
|
+
{% if form.name.errors %}
|
|
96
|
+
<p class="text-red-500 text-sm mt-1">{{ form.name.errors.0 }}</p>
|
|
97
|
+
{% endif %}
|
|
98
|
+
<p class="text-gray-400 text-xs mt-1">A descriptive name for this connection</p>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
<!-- Centralized Connection Fields -->
|
|
102
|
+
<div id="centralizedFields">
|
|
103
|
+
<!-- Connection Mode Selection -->
|
|
104
|
+
<div class="mb-6">
|
|
105
|
+
<label class="block text-sm font-medium text-gray-300 mb-3">
|
|
106
|
+
Connection Mode
|
|
107
|
+
</label>
|
|
108
|
+
<div class="flex gap-4">
|
|
109
|
+
<label class="flex items-center gap-2 cursor-pointer">
|
|
110
|
+
<input type="radio" name="connection_mode" value="cloud" class="radio radio-sm radio-primary" checked>
|
|
111
|
+
<span class="text-sm text-gray-300">Cloud ID</span>
|
|
112
|
+
</label>
|
|
113
|
+
<label class="flex items-center gap-2 cursor-pointer">
|
|
114
|
+
<input type="radio" name="connection_mode" value="url" class="radio radio-sm radio-primary">
|
|
115
|
+
<span class="text-sm text-gray-300">Elastic Node URL</span>
|
|
116
|
+
</label>
|
|
117
|
+
</div>
|
|
118
|
+
<p class="text-gray-400 text-xs mt-2">Choose how to connect to your Elasticsearch cluster</p>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
<!-- Cloud ID Field -->
|
|
122
|
+
<div id="cloudIdField" class="mb-6">
|
|
123
|
+
<label for="{{ form.cloud_id.id_for_label }}" class="block text-sm font-medium text-gray-300 mb-2">
|
|
124
|
+
Cloud ID
|
|
125
|
+
</label>
|
|
126
|
+
{{ form.cloud_id }}
|
|
127
|
+
<p class="text-gray-400 text-xs mt-1">Your Elastic Cloud deployment ID</p>
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
<!-- Node URL and Port Fields -->
|
|
131
|
+
<div id="nodeUrlField" class="hidden mb-6">
|
|
132
|
+
<label class="block text-sm font-medium text-gray-300 mb-2">
|
|
133
|
+
Elastic Node URL
|
|
134
|
+
</label>
|
|
135
|
+
<div class="flex gap-3">
|
|
136
|
+
<div class="flex-1">
|
|
137
|
+
{{ form.host }}
|
|
138
|
+
</div>
|
|
139
|
+
<div class="w-24">
|
|
140
|
+
{{ form.port }}
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
<p class="text-gray-400 text-xs mt-1">URL and port of your Elasticsearch node (e.g., https://elasticsearch.example.com:9200)</p>
|
|
144
|
+
</div>
|
|
145
|
+
|
|
146
|
+
<!-- Authentication Section -->
|
|
147
|
+
<div class="mb-6">
|
|
148
|
+
<label class="block text-sm font-medium text-gray-300 mb-3">
|
|
149
|
+
Authentication
|
|
150
|
+
</label>
|
|
151
|
+
<div class="flex gap-4 mb-4">
|
|
152
|
+
<label class="flex items-center gap-2 cursor-pointer">
|
|
153
|
+
<input type="radio" name="auth_type" value="basic" class="radio radio-sm radio-primary" checked>
|
|
154
|
+
<span class="text-sm text-gray-300">Username/Password</span>
|
|
155
|
+
</label>
|
|
156
|
+
<label class="flex items-center gap-2 cursor-pointer">
|
|
157
|
+
<input type="radio" name="auth_type" value="apiKey" class="radio radio-sm radio-primary">
|
|
158
|
+
<span class="text-sm text-gray-300">API Key</span>
|
|
159
|
+
</label>
|
|
160
|
+
</div>
|
|
161
|
+
|
|
162
|
+
<!-- Username/Password Fields -->
|
|
163
|
+
<div id="basicAuthFields">
|
|
164
|
+
<div class="mb-4">
|
|
165
|
+
<label for="{{ form.username.id_for_label }}" class="block text-sm font-medium text-gray-300 mb-2">
|
|
166
|
+
Username
|
|
167
|
+
</label>
|
|
168
|
+
{{ form.username }}
|
|
169
|
+
<p class="text-gray-400 text-xs mt-1">Elasticsearch username</p>
|
|
170
|
+
</div>
|
|
171
|
+
<div class="mb-4">
|
|
172
|
+
<label for="{{ form.password.id_for_label }}" class="block text-sm font-medium text-gray-300 mb-2">
|
|
173
|
+
Password
|
|
174
|
+
</label>
|
|
175
|
+
{{ form.password }}
|
|
176
|
+
<p class="text-gray-400 text-xs mt-1">Elasticsearch password</p>
|
|
177
|
+
</div>
|
|
178
|
+
</div>
|
|
179
|
+
|
|
180
|
+
<!-- API Key Field -->
|
|
181
|
+
<div id="apiKeyField" class="hidden">
|
|
182
|
+
<label for="{{ form.api_key.id_for_label }}" class="block text-sm font-medium text-gray-300 mb-2">
|
|
183
|
+
API Key
|
|
184
|
+
</label>
|
|
185
|
+
{{ form.api_key }}
|
|
186
|
+
<p class="text-gray-400 text-xs mt-1">Base64-encoded API key for authentication</p>
|
|
187
|
+
</div>
|
|
188
|
+
</div>
|
|
189
|
+
|
|
190
|
+
<!-- Allow Self-Signed Certificates. Lives inside centralizedFields so it is
|
|
191
|
+
hidden for agent enrollment, where TLS verification is not applicable. -->
|
|
192
|
+
<div id="allowSelfSignedField" class="mb-4">
|
|
193
|
+
<label class="flex items-center gap-3 cursor-pointer">
|
|
194
|
+
{{ form.allow_self_signed_certs }}
|
|
195
|
+
<span class="text-sm font-medium text-gray-300">Allow self-signed certificates</span>
|
|
196
|
+
</label>
|
|
197
|
+
<p class="text-gray-400 text-xs mt-1 ml-6">
|
|
198
|
+
Skip TLS certificate verification (required for self-signed or private CA certs)
|
|
199
|
+
</p>
|
|
200
|
+
</div>
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
<!-- Logstash Agent Connection Fields -->
|
|
204
|
+
<div id="agentFields" class="hidden">
|
|
205
|
+
<!-- Notice -->
|
|
206
|
+
<div class="p-4 mb-4 bg-blue-900/20 border border-blue-600 rounded-lg">
|
|
207
|
+
<p class="text-blue-300 text-sm">
|
|
208
|
+
Enrolling LogstashAgent makes this Logstash instance fully managed by LogstashUI. Future applies may overwrite manual changes made directly on the host, including config files, pipelines, and keystore contents. Migrate any desired local configuration into an Agent Policy before enrolling production nodes.
|
|
209
|
+
</p>
|
|
210
|
+
<div class="mt-3 pt-3 border-t border-blue-600/30">
|
|
211
|
+
<div class="group relative inline-block">
|
|
212
|
+
<button type="button" class="text-xs text-blue-400 hover:text-blue-300 underline decoration-dotted cursor-help">
|
|
213
|
+
What system level changes does LogstashAgent perform?
|
|
214
|
+
</button>
|
|
215
|
+
<div class="invisible group-hover:visible opacity-0 group-hover:opacity-100 transition-opacity duration-200 absolute left-0 top-full mt-2 w-96 bg-gray-800 border border-gray-600 rounded-lg shadow-xl p-4 z-50">
|
|
216
|
+
<h4 class="text-sm font-semibold text-white mb-3">System Changes Made by LogstashAgent</h4>
|
|
217
|
+
|
|
218
|
+
<div class="mb-3">
|
|
219
|
+
<p class="text-xs font-medium text-gray-300 mb-1">Ownership Changes:</p>
|
|
220
|
+
<ul class="text-xs text-gray-400 space-y-1 ml-3">
|
|
221
|
+
<li><code class="text-gray-300">/etc/logstash</code> → logstash:logstash (recursive)</li>
|
|
222
|
+
<li><code class="text-gray-300">/var/log/logstash</code> → logstash:logstash (recursive)</li>
|
|
223
|
+
<li><code class="text-gray-300">/usr/share/logstash/data</code> → logstash:logstash (recursive)</li>
|
|
224
|
+
</ul>
|
|
225
|
+
</div>
|
|
226
|
+
|
|
227
|
+
<div class="mb-3">
|
|
228
|
+
<p class="text-xs font-medium text-gray-300 mb-1">Sudo Permissions:</p>
|
|
229
|
+
<p class="text-xs text-gray-400 ml-3"><code class="text-gray-300">/etc/sudoers.d/logstash-agent</code> - Grants logstash user sudo access for service management and file operations</p>
|
|
230
|
+
</div>
|
|
231
|
+
|
|
232
|
+
<div>
|
|
233
|
+
<p class="text-xs font-medium text-gray-300 mb-1">Systemd:</p>
|
|
234
|
+
<p class="text-xs text-gray-400 ml-3"><code class="text-gray-300">systemctl daemon-reload</code> - Reload systemd configuration</p>
|
|
235
|
+
</div>
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
|
|
241
|
+
<!-- Agent Policy Dropdown -->
|
|
242
|
+
<div class="mb-4">
|
|
243
|
+
<label for="agentPolicy" class="block text-sm font-medium text-gray-300 mb-2">
|
|
244
|
+
Agent Policy <span class="text-red-500">*</span>
|
|
245
|
+
</label>
|
|
246
|
+
<select id="agentPolicy" name="agent_policy" class="select select-bordered w-full">
|
|
247
|
+
<option value="">Select a policy...</option>
|
|
248
|
+
<option value="add_new" class="font-bold text-primary">+ Add Agent Policy</option>
|
|
249
|
+
</select>
|
|
250
|
+
<p class="text-gray-400 text-xs mt-1">Select the policy to apply to this agent. The enrollment token and install commands appear once a policy is chosen.</p>
|
|
251
|
+
</div>
|
|
252
|
+
|
|
253
|
+
<!-- Enrollment Token Dropdown (hidden until a policy is explicitly selected) -->
|
|
254
|
+
<div id="enrollmentTokenSection" class="mb-4 hidden">
|
|
255
|
+
<label for="enrollmentToken" class="block text-sm font-medium text-gray-300 mb-2">
|
|
256
|
+
Enrollment Token <span class="text-red-500">*</span>
|
|
257
|
+
</label>
|
|
258
|
+
<select id="enrollmentToken" name="enrollment_token" class="select select-bordered w-full">
|
|
259
|
+
<option value="">Select a token...</option>
|
|
260
|
+
<option value="add_new" class="font-bold text-primary">+ Add Token</option>
|
|
261
|
+
</select>
|
|
262
|
+
<p class="text-gray-400 text-xs mt-1">Select the enrollment token to use for this agent</p>
|
|
263
|
+
</div>
|
|
264
|
+
|
|
265
|
+
<!-- Linux Installation Commands -->
|
|
266
|
+
<div id="linuxCommandsSection" class="mb-4 hidden">
|
|
267
|
+
<label class="form-label mb-2 block">Linux</label>
|
|
268
|
+
|
|
269
|
+
<!-- Install Logstash Checkbox (DEFAULT / SIMULATE+SYSTEM only; hidden for EMBEDDED and SIMULATE+VERSION) -->
|
|
270
|
+
<div id="installLogstashRow" class="mb-3">
|
|
271
|
+
<label class="flex items-center gap-2 cursor-pointer">
|
|
272
|
+
<input type="checkbox" id="installLogstashCheckbox" class="checkbox checkbox-sm">
|
|
273
|
+
<span class="text-sm text-gray-300">Install Logstash</span>
|
|
274
|
+
</label>
|
|
275
|
+
<p id="installLogstashHint" class="hidden text-xs text-gray-500 mt-1 ml-6"></p>
|
|
276
|
+
</div>
|
|
277
|
+
|
|
278
|
+
<!-- Managed policies: the agent installs Logstash itself, so no manual install option -->
|
|
279
|
+
<div id="managedLogstashNotice" class="hidden mb-3 p-3 bg-blue-900/20 border border-blue-600 rounded-lg">
|
|
280
|
+
<p class="text-blue-300 text-sm">
|
|
281
|
+
With this policy type the agent will install and manage Logstash for you. Please make sure that's configured in the policy.
|
|
282
|
+
</p>
|
|
283
|
+
</div>
|
|
284
|
+
|
|
285
|
+
<!-- Package Manager Selection (shown when Install Logstash is checked) -->
|
|
286
|
+
<div id="packageManagerSection" class="hidden mb-3 ml-6">
|
|
287
|
+
<label class="block text-sm text-gray-400 mb-2">Package Manager:</label>
|
|
288
|
+
<div class="flex gap-4">
|
|
289
|
+
<label class="flex items-center gap-2 cursor-pointer">
|
|
290
|
+
<input type="radio" name="package_manager" value="apt" class="radio radio-sm" checked>
|
|
291
|
+
<span class="text-sm text-gray-300">apt (Debian/Ubuntu)</span>
|
|
292
|
+
</label>
|
|
293
|
+
<label class="flex items-center gap-2 cursor-pointer">
|
|
294
|
+
<input type="radio" name="package_manager" value="yum" class="radio radio-sm">
|
|
295
|
+
<span class="text-sm text-gray-300">yum (RHEL/CentOS)</span>
|
|
296
|
+
</label>
|
|
297
|
+
</div>
|
|
298
|
+
</div>
|
|
299
|
+
|
|
300
|
+
<!-- Localhost Warning -->
|
|
301
|
+
<div id="localhostWarning" class="hidden p-3 mb-3 bg-yellow-900/20 border border-yellow-600 rounded-lg">
|
|
302
|
+
<p class="text-yellow-300 text-sm mb-2">
|
|
303
|
+
⚠️ It looks like you're hosting LogstashUI on your local machine.
|
|
304
|
+
</p>
|
|
305
|
+
<label class="block text-yellow-200 text-sm mb-2">
|
|
306
|
+
Enter the hostname or IP address that LogstashAgent should use to reach this LogstashUI instance:
|
|
307
|
+
</label>
|
|
308
|
+
<input
|
|
309
|
+
type="text"
|
|
310
|
+
id="customLogstashUIUrl"
|
|
311
|
+
class="w-full px-3 py-2 bg-gray-900 border border-yellow-600 rounded-md text-white text-sm focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:border-transparent"
|
|
312
|
+
placeholder="e.g., https://logstash-ui.example.com or http://192.168.1.100:8000"
|
|
313
|
+
oninput="updateLinuxCommandsUrl()"
|
|
314
|
+
>
|
|
315
|
+
</div>
|
|
316
|
+
<div class="bg-gray-900 border border-gray-700 rounded-lg p-4 font-mono text-sm">
|
|
317
|
+
<div class="flex justify-between items-center mb-2">
|
|
318
|
+
<span class="text-gray-400 text-xs">BASH</span>
|
|
319
|
+
<button type="button" onclick="copyToClipboard('linuxCommands', event)" class="text-blue-400 hover:text-blue-300 text-xs">
|
|
320
|
+
Copy
|
|
321
|
+
</button>
|
|
322
|
+
</div>
|
|
323
|
+
<pre id="linuxCommands" class="text-green-400 whitespace-pre-wrap break-all"><code>curl -LO https://github.com/elastic/LogstashAgent/releases/download/v{{ preferred_agent_version }}/logstash-agent-linux-amd64.tar.gz
|
|
324
|
+
tar -xzf logstash-agent-linux-amd64.tar.gz
|
|
325
|
+
sudo ./logstash-agent/logstash-agent install --enroll {enrollment_token} --logstash-ui-url {url} --yes
|
|
326
|
+
sudo systemctl enable logstash-agent
|
|
327
|
+
sudo systemctl start logstash-agent</code></pre>
|
|
328
|
+
</div>
|
|
329
|
+
</div>
|
|
330
|
+
</div>
|
|
331
|
+
|
|
332
|
+
<div class="form-actions pt-6 mt-6 border-t border-gray-700">
|
|
333
|
+
<button type="button" onclick="closeFlyout()" class="btn btn-secondary">
|
|
334
|
+
Cancel
|
|
335
|
+
</button>
|
|
336
|
+
<button id="saveConnectionBtn" type="submit" class="btn btn-primary">
|
|
337
|
+
Save Connection
|
|
338
|
+
</button>
|
|
339
|
+
</div>
|
|
340
|
+
<div class="htmx-indicator loading">Saving...</div>
|
|
341
|
+
</form>
|
|
342
|
+
</div>
|
|
343
|
+
</div>
|
|
344
|
+
</div>
|
|
345
|
+
</div>
|
|
346
|
+
|
|
347
|
+
<script>
|
|
348
|
+
// Track whether the modal is in 'add' or 'edit' mode
|
|
349
|
+
window.connectionEditMode = 'add';
|
|
350
|
+
window.editConnectionId = null;
|
|
351
|
+
|
|
352
|
+
function openFlyout() {
|
|
353
|
+
document.getElementById('connectionFormFlyout').classList.remove('hidden');
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function closeFlyout() {
|
|
357
|
+
document.getElementById('connectionFormFlyout').classList.add('hidden');
|
|
358
|
+
_resetConnectionModalToAddMode();
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function _resetConnectionModalToAddMode() {
|
|
362
|
+
if (window.connectionEditMode !== 'edit') return;
|
|
363
|
+
|
|
364
|
+
window.connectionEditMode = 'add';
|
|
365
|
+
window.editConnectionId = null;
|
|
366
|
+
|
|
367
|
+
// Restore form action to AddConnection
|
|
368
|
+
const form = document.getElementById('connectionForm');
|
|
369
|
+
form.setAttribute('hx-post', '/ConnectionManager/AddConnection');
|
|
370
|
+
htmx.process(form);
|
|
371
|
+
|
|
372
|
+
// Restore title and button
|
|
373
|
+
document.getElementById('connectionModalTitle').textContent = 'Add New Connection';
|
|
374
|
+
const saveBtn = document.getElementById('saveConnectionBtn');
|
|
375
|
+
if (saveBtn) saveBtn.textContent = 'Save Connection';
|
|
376
|
+
|
|
377
|
+
// Hide credential hint
|
|
378
|
+
document.getElementById('credentialReentryHint').classList.add('hidden');
|
|
379
|
+
|
|
380
|
+
// Reset form values (radios go back to their HTML default but don't fire change events,
|
|
381
|
+
// so we must explicitly restore field visibility to match those defaults)
|
|
382
|
+
form.reset();
|
|
383
|
+
document.getElementById('connectionErrorContainer').innerHTML = '';
|
|
384
|
+
|
|
385
|
+
// Restore connection mode visibility to default (Cloud ID selected)
|
|
386
|
+
document.getElementById('cloudIdField').classList.remove('hidden');
|
|
387
|
+
document.getElementById('nodeUrlField').classList.add('hidden');
|
|
388
|
+
|
|
389
|
+
// Restore auth type visibility to default (Username/Password selected)
|
|
390
|
+
document.getElementById('basicAuthFields').classList.remove('hidden');
|
|
391
|
+
document.getElementById('apiKeyField').classList.add('hidden');
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Open the connection modal in edit mode, pre-filling all non-credential fields.
|
|
396
|
+
* Only supports CENTRALIZED connections.
|
|
397
|
+
*/
|
|
398
|
+
window.openEditConnection = async function(connectionId) {
|
|
399
|
+
try {
|
|
400
|
+
const response = await fetch(`/ConnectionManager/GetConnection/${connectionId}/`, {
|
|
401
|
+
headers: { 'X-CSRFToken': getCsrfToken() }
|
|
402
|
+
});
|
|
403
|
+
const data = await response.json();
|
|
404
|
+
|
|
405
|
+
if (!data.success) {
|
|
406
|
+
showToast(data.error || 'Failed to load connection details', 'error');
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
const conn = data.connection;
|
|
411
|
+
window.connectionEditMode = 'edit';
|
|
412
|
+
window.editConnectionId = connectionId;
|
|
413
|
+
|
|
414
|
+
// Switch the form action to UpdateConnection
|
|
415
|
+
const form = document.getElementById('connectionForm');
|
|
416
|
+
form.setAttribute('hx-post', `/ConnectionManager/UpdateConnection/${connectionId}/`);
|
|
417
|
+
htmx.process(form);
|
|
418
|
+
|
|
419
|
+
// Update title and save button
|
|
420
|
+
document.getElementById('connectionModalTitle').textContent = 'Edit Connection';
|
|
421
|
+
const saveBtn = document.getElementById('saveConnectionBtn');
|
|
422
|
+
if (saveBtn) {
|
|
423
|
+
saveBtn.textContent = 'Update Connection';
|
|
424
|
+
saveBtn.classList.remove('hidden');
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// Lock to centralized mode
|
|
428
|
+
document.getElementById('connectionTypeField').value = 'CENTRALIZED';
|
|
429
|
+
document.getElementById('centralizedFields').classList.remove('hidden');
|
|
430
|
+
document.getElementById('agentFields').classList.add('hidden');
|
|
431
|
+
document.getElementById('connectionNameField').classList.remove('hidden');
|
|
432
|
+
|
|
433
|
+
// Show credential re-entry hint
|
|
434
|
+
document.getElementById('credentialReentryHint').classList.remove('hidden');
|
|
435
|
+
|
|
436
|
+
// Clear any previous errors
|
|
437
|
+
document.getElementById('connectionErrorContainer').innerHTML = '';
|
|
438
|
+
|
|
439
|
+
// -- Pre-fill name --
|
|
440
|
+
const nameInput = document.querySelector('[name="name"]');
|
|
441
|
+
if (nameInput) nameInput.value = conn.name;
|
|
442
|
+
|
|
443
|
+
// -- Pre-fill connection mode (cloud vs url) --
|
|
444
|
+
const modeRadios = document.querySelectorAll('input[name="connection_mode"]');
|
|
445
|
+
modeRadios.forEach(r => { r.checked = r.value === conn.connection_mode; });
|
|
446
|
+
|
|
447
|
+
if (conn.connection_mode === 'cloud') {
|
|
448
|
+
document.getElementById('cloudIdField').classList.remove('hidden');
|
|
449
|
+
document.getElementById('nodeUrlField').classList.add('hidden');
|
|
450
|
+
const cloudIdInput = document.querySelector('[name="cloud_id"]');
|
|
451
|
+
if (cloudIdInput) cloudIdInput.value = conn.cloud_id;
|
|
452
|
+
} else {
|
|
453
|
+
document.getElementById('cloudIdField').classList.add('hidden');
|
|
454
|
+
document.getElementById('nodeUrlField').classList.remove('hidden');
|
|
455
|
+
const hostInput = document.querySelector('[name="host"]');
|
|
456
|
+
const portInput = document.querySelector('[name="port"]');
|
|
457
|
+
if (hostInput) hostInput.value = conn.host;
|
|
458
|
+
if (portInput) portInput.value = conn.port;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// -- Pre-fill auth type (credentials intentionally blank) --
|
|
462
|
+
const authRadios = document.querySelectorAll('input[name="auth_type"]');
|
|
463
|
+
authRadios.forEach(r => { r.checked = r.value === conn.auth_type; });
|
|
464
|
+
|
|
465
|
+
if (conn.auth_type === 'basic') {
|
|
466
|
+
document.getElementById('basicAuthFields').classList.remove('hidden');
|
|
467
|
+
document.getElementById('apiKeyField').classList.add('hidden');
|
|
468
|
+
const usernameInput = document.querySelector('[name="username"]');
|
|
469
|
+
const passwordInput = document.querySelector('[name="password"]');
|
|
470
|
+
if (usernameInput) usernameInput.value = conn.username;
|
|
471
|
+
if (passwordInput) passwordInput.value = '';
|
|
472
|
+
} else {
|
|
473
|
+
document.getElementById('basicAuthFields').classList.add('hidden');
|
|
474
|
+
document.getElementById('apiKeyField').classList.remove('hidden');
|
|
475
|
+
const apiKeyInput = document.querySelector('[name="api_key"]');
|
|
476
|
+
if (apiKeyInput) apiKeyInput.value = '';
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// -- Pre-fill allow_self_signed_certs --
|
|
480
|
+
const selfSignedCheckbox = document.querySelector('[name="allow_self_signed_certs"]');
|
|
481
|
+
if (selfSignedCheckbox) selfSignedCheckbox.checked = !!conn.allow_self_signed_certs;
|
|
482
|
+
|
|
483
|
+
openFlyout();
|
|
484
|
+
} catch (err) {
|
|
485
|
+
console.error('Error loading connection for edit:', err);
|
|
486
|
+
showToast('Failed to load connection details', 'error');
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
// Handle form submission and front end validation
|
|
494
|
+
document.getElementById('connectionForm').addEventListener('submit', function(e) {
|
|
495
|
+
// Only validate visible fields
|
|
496
|
+
if (document.getElementById('connectionTypeField').value === 'AGENT') {
|
|
497
|
+
// Validate agent policy is selected
|
|
498
|
+
const agentPolicy = document.querySelector('[name="agent_policy"]');
|
|
499
|
+
if (!agentPolicy || !agentPolicy.value) {
|
|
500
|
+
e.preventDefault();
|
|
501
|
+
e.stopPropagation();
|
|
502
|
+
showToast('Please select an agent policy', 'error');
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
} else {
|
|
506
|
+
// For centralized form, validate based on selected auth type
|
|
507
|
+
const authType = document.querySelector('input[name="auth_type"]:checked').value;
|
|
508
|
+
let isValid = true;
|
|
509
|
+
|
|
510
|
+
// Always validate username/password if basic auth is selected
|
|
511
|
+
if (authType === 'basic') {
|
|
512
|
+
const username = document.querySelector('[name="username"]');
|
|
513
|
+
const password = document.querySelector('[name="password"]');
|
|
514
|
+
|
|
515
|
+
// In edit mode credentials are always required; in add mode they are always required too
|
|
516
|
+
if (!username.value.trim() || !password.value.trim()) {
|
|
517
|
+
isValid = false;
|
|
518
|
+
if (!username.value.trim()) username.reportValidity();
|
|
519
|
+
if (!password.value.trim()) {
|
|
520
|
+
showToast('Password is required', 'error');
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
} else {
|
|
524
|
+
// Validate API key if API key auth is selected
|
|
525
|
+
const apiKey = document.querySelector('[name="api_key"]');
|
|
526
|
+
if (!apiKey.value.trim()) {
|
|
527
|
+
isValid = false;
|
|
528
|
+
showToast('API Key is required', 'error');
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
if (!isValid) {
|
|
533
|
+
e.preventDefault();
|
|
534
|
+
e.stopPropagation();
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
// Load policies from server and populate dropdown
|
|
542
|
+
async function loadAgentPolicies() {
|
|
543
|
+
try {
|
|
544
|
+
// for_enroll=1 excludes Embedded (compose/auto; not token-enrolled)
|
|
545
|
+
const response = await fetch('/ConnectionManager/GetPolicies/?for_enroll=1', {
|
|
546
|
+
method: 'GET',
|
|
547
|
+
headers: {
|
|
548
|
+
'X-CSRFToken': getCsrfToken()
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
const data = await response.json();
|
|
553
|
+
|
|
554
|
+
if (data.success && data.policies) {
|
|
555
|
+
const agentPolicySelect = document.getElementById('agentPolicy');
|
|
556
|
+
if (agentPolicySelect) {
|
|
557
|
+
// Clear existing options except "Select a policy..." and "+ Add Agent Policy"
|
|
558
|
+
const selectOption = agentPolicySelect.querySelector('option[value=""]');
|
|
559
|
+
const addNewOption = agentPolicySelect.querySelector('option[value="add_new"]');
|
|
560
|
+
agentPolicySelect.innerHTML = '';
|
|
561
|
+
|
|
562
|
+
// Re-add the select and add new options
|
|
563
|
+
if (selectOption) agentPolicySelect.appendChild(selectOption);
|
|
564
|
+
if (addNewOption) agentPolicySelect.appendChild(addNewOption);
|
|
565
|
+
|
|
566
|
+
// Add all policies from server
|
|
567
|
+
data.policies.forEach(policy => {
|
|
568
|
+
const option = document.createElement('option');
|
|
569
|
+
option.value = policy.name.toLowerCase();
|
|
570
|
+
option.textContent = policy.name;
|
|
571
|
+
option.dataset.policyId = policy.id;
|
|
572
|
+
option.dataset.policyType = policy.policy_type || 'DEFAULT';
|
|
573
|
+
option.dataset.logstashSource = policy.logstash_source || 'SYSTEM';
|
|
574
|
+
|
|
575
|
+
// Insert before "+ Add Agent Policy" option
|
|
576
|
+
agentPolicySelect.insertBefore(option, addNewOption);
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
// Deliberately do NOT preselect a policy: the user must choose one
|
|
580
|
+
// before the enrollment token and install commands are revealed.
|
|
581
|
+
agentPolicySelect.value = '';
|
|
582
|
+
syncEnrollmentGate();
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
} catch (error) {
|
|
586
|
+
console.error('Error loading agent policies:', error);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// Load policies on page load
|
|
591
|
+
loadAgentPolicies();
|
|
592
|
+
|
|
593
|
+
// Handle agent policy selection change
|
|
594
|
+
const agentPolicySelect = document.getElementById('agentPolicy');
|
|
595
|
+
const linuxCommandsSection = document.getElementById('linuxCommandsSection');
|
|
596
|
+
const saveConnectionBtn = document.getElementById('saveConnectionBtn');
|
|
597
|
+
|
|
598
|
+
if (agentPolicySelect) {
|
|
599
|
+
agentPolicySelect.addEventListener('change', async function(e) {
|
|
600
|
+
if (this.value === 'add_new') {
|
|
601
|
+
// Show prompt to add new policy
|
|
602
|
+
const policyName = await ConfirmationModal.prompt(
|
|
603
|
+
'Enter a name for the new policy:',
|
|
604
|
+
'',
|
|
605
|
+
'Add New Policy',
|
|
606
|
+
'e.g., Production Policy'
|
|
607
|
+
);
|
|
608
|
+
|
|
609
|
+
if (policyName && policyName.trim()) {
|
|
610
|
+
const trimmedName = policyName.trim();
|
|
611
|
+
|
|
612
|
+
// Create the policy
|
|
613
|
+
try {
|
|
614
|
+
const response = await fetch('/ConnectionManager/AddPolicy/', {
|
|
615
|
+
method: 'POST',
|
|
616
|
+
headers: {
|
|
617
|
+
'Content-Type': 'application/json',
|
|
618
|
+
'X-CSRFToken': getCsrfToken()
|
|
619
|
+
},
|
|
620
|
+
body: JSON.stringify({
|
|
621
|
+
name: trimmedName,
|
|
622
|
+
settings_path: '/etc/logstash/',
|
|
623
|
+
logs_path: '/var/log/logstash',
|
|
624
|
+
logstash_yml: '',
|
|
625
|
+
jvm_options: '',
|
|
626
|
+
log4j2_properties: ''
|
|
627
|
+
})
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
const data = await response.json();
|
|
631
|
+
|
|
632
|
+
if (data.success) {
|
|
633
|
+
showToast(data.message || 'Policy created successfully', 'success');
|
|
634
|
+
|
|
635
|
+
// Reload policies to include the new one
|
|
636
|
+
await loadAgentPolicies();
|
|
637
|
+
|
|
638
|
+
// Select the newly created policy (the user explicitly chose to create it)
|
|
639
|
+
const newOption = Array.from(agentPolicySelect.options)
|
|
640
|
+
.find(opt => opt.dataset.policyId === String(data.policy_id));
|
|
641
|
+
if (newOption) {
|
|
642
|
+
agentPolicySelect.value = newOption.value;
|
|
643
|
+
}
|
|
644
|
+
syncInstallLogstashVisibility();
|
|
645
|
+
syncEnrollmentGate();
|
|
646
|
+
|
|
647
|
+
// Load enrollment tokens for the new policy
|
|
648
|
+
await loadEnrollmentTokens(data.policy_id);
|
|
649
|
+
} else {
|
|
650
|
+
showToast(data.error || 'Failed to create policy', 'error');
|
|
651
|
+
// Reset to empty selection
|
|
652
|
+
agentPolicySelect.value = '';
|
|
653
|
+
}
|
|
654
|
+
} catch (error) {
|
|
655
|
+
console.error('Error creating policy:', error);
|
|
656
|
+
showToast('Failed to create policy: ' + error.message, 'error');
|
|
657
|
+
// Reset to empty selection
|
|
658
|
+
agentPolicySelect.value = '';
|
|
659
|
+
}
|
|
660
|
+
} else {
|
|
661
|
+
// User cancelled, reset to empty selection
|
|
662
|
+
agentPolicySelect.value = '';
|
|
663
|
+
}
|
|
664
|
+
} else if (this.value && this.value !== '') {
|
|
665
|
+
// Load enrollment tokens for selected policy
|
|
666
|
+
const selectedOption = this.options[this.selectedIndex];
|
|
667
|
+
const policyId = selectedOption.dataset.policyId;
|
|
668
|
+
syncInstallLogstashVisibility();
|
|
669
|
+
syncEnrollmentGate();
|
|
670
|
+
|
|
671
|
+
if (policyId) {
|
|
672
|
+
await loadEnrollmentTokens(policyId);
|
|
673
|
+
}
|
|
674
|
+
// Refresh command snippet if a token is already selected
|
|
675
|
+
const enrollmentTokenSelect = document.getElementById('enrollmentToken');
|
|
676
|
+
if (enrollmentTokenSelect && enrollmentTokenSelect.selectedIndex >= 0) {
|
|
677
|
+
const tok = enrollmentTokenSelect.options[enrollmentTokenSelect.selectedIndex];
|
|
678
|
+
if (tok && tok.dataset.encodedToken) {
|
|
679
|
+
updateLinuxCommands(tok.dataset.encodedToken);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
} else {
|
|
683
|
+
// No policy selected: clear tokens and hide token + install commands
|
|
684
|
+
const enrollmentTokenSelect = document.getElementById('enrollmentToken');
|
|
685
|
+
if (enrollmentTokenSelect) {
|
|
686
|
+
enrollmentTokenSelect.innerHTML = '<option value="">Select a token...</option>';
|
|
687
|
+
}
|
|
688
|
+
syncEnrollmentGate();
|
|
689
|
+
}
|
|
690
|
+
});
|
|
691
|
+
|
|
692
|
+
// Load enrollment tokens on page load if agent fields are visible and policy is selected
|
|
693
|
+
const agentFields = document.getElementById('agentFields');
|
|
694
|
+
if (agentFields && !agentFields.classList.contains('hidden') && agentPolicySelect.value && agentPolicySelect.value !== '' && agentPolicySelect.value !== 'add_new') {
|
|
695
|
+
// Get policy ID from selected option
|
|
696
|
+
const selectedOption = agentPolicySelect.options[agentPolicySelect.selectedIndex];
|
|
697
|
+
const policyId = selectedOption.dataset.policyId;
|
|
698
|
+
|
|
699
|
+
if (policyId) {
|
|
700
|
+
loadEnrollmentTokens(policyId);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
// Function to load enrollment tokens for a policy
|
|
706
|
+
async function loadEnrollmentTokens(policyId) {
|
|
707
|
+
try {
|
|
708
|
+
const response = await fetch(`/ConnectionManager/GetEnrollmentTokens/?policy_id=${policyId}`, {
|
|
709
|
+
method: 'GET',
|
|
710
|
+
headers: {
|
|
711
|
+
'X-CSRFToken': getCsrfToken()
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
|
|
715
|
+
const data = await response.json();
|
|
716
|
+
|
|
717
|
+
const enrollmentTokenSelect = document.getElementById('enrollmentToken');
|
|
718
|
+
const enrollmentTokenSection = document.getElementById('enrollmentTokenSection');
|
|
719
|
+
|
|
720
|
+
if (data.success && data.tokens && data.tokens.length > 0) {
|
|
721
|
+
// Clear existing options and rebuild
|
|
722
|
+
enrollmentTokenSelect.innerHTML = '<option value="">Select a token...</option>';
|
|
723
|
+
|
|
724
|
+
// Add enrollment tokens
|
|
725
|
+
data.tokens.forEach(token => {
|
|
726
|
+
const option = document.createElement('option');
|
|
727
|
+
option.value = token.id;
|
|
728
|
+
option.textContent = token.name;
|
|
729
|
+
option.dataset.encodedToken = token.encoded_token;
|
|
730
|
+
enrollmentTokenSelect.appendChild(option);
|
|
731
|
+
});
|
|
732
|
+
|
|
733
|
+
// Add the "+ Add Token" option at the end
|
|
734
|
+
const addNewOption = document.createElement('option');
|
|
735
|
+
addNewOption.value = 'add_new';
|
|
736
|
+
addNewOption.textContent = '+ Add Token';
|
|
737
|
+
addNewOption.className = 'font-bold text-primary';
|
|
738
|
+
enrollmentTokenSelect.appendChild(addNewOption);
|
|
739
|
+
|
|
740
|
+
// Auto-select first token
|
|
741
|
+
if (data.tokens.length > 0) {
|
|
742
|
+
enrollmentTokenSelect.value = data.tokens[0].id;
|
|
743
|
+
enrollmentTokenSelect.dispatchEvent(new Event('change'));
|
|
744
|
+
}
|
|
745
|
+
} else {
|
|
746
|
+
// Clear enrollment token dropdown if no tokens, but keep "+ Add Token" option
|
|
747
|
+
enrollmentTokenSelect.innerHTML = '<option value="">Select a token...</option>';
|
|
748
|
+
const addNewOption = document.createElement('option');
|
|
749
|
+
addNewOption.value = 'add_new';
|
|
750
|
+
addNewOption.textContent = '+ Add Token';
|
|
751
|
+
addNewOption.className = 'font-bold text-primary';
|
|
752
|
+
enrollmentTokenSelect.appendChild(addNewOption);
|
|
753
|
+
}
|
|
754
|
+
} catch (error) {
|
|
755
|
+
console.error('Error loading enrollment tokens:', error);
|
|
756
|
+
showToast('Failed to load enrollment tokens: ' + error.message, 'error');
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
// Handle enrollment token selection change
|
|
761
|
+
const enrollmentTokenSelect = document.getElementById('enrollmentToken');
|
|
762
|
+
if (enrollmentTokenSelect) {
|
|
763
|
+
enrollmentTokenSelect.addEventListener('change', async function() {
|
|
764
|
+
if (this.value === 'add_new') {
|
|
765
|
+
// Show prompt to add new enrollment token
|
|
766
|
+
const tokenName = await ConfirmationModal.prompt(
|
|
767
|
+
'Enter a name for the enrollment token:',
|
|
768
|
+
'',
|
|
769
|
+
'Add Enrollment Token',
|
|
770
|
+
'e.g., Production Token'
|
|
771
|
+
);
|
|
772
|
+
|
|
773
|
+
if (tokenName && tokenName.trim()) {
|
|
774
|
+
const trimmedName = tokenName.trim();
|
|
775
|
+
|
|
776
|
+
// Get current policy ID
|
|
777
|
+
const agentPolicySelect = document.getElementById('agentPolicy');
|
|
778
|
+
const selectedPolicyOption = agentPolicySelect.options[agentPolicySelect.selectedIndex];
|
|
779
|
+
const policyId = selectedPolicyOption.dataset.policyId;
|
|
780
|
+
|
|
781
|
+
if (!policyId) {
|
|
782
|
+
showToast('Please select a policy first', 'error');
|
|
783
|
+
this.value = '';
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
// Create the enrollment token
|
|
788
|
+
try {
|
|
789
|
+
const response = await fetch('/ConnectionManager/AddEnrollmentToken/', {
|
|
790
|
+
method: 'POST',
|
|
791
|
+
headers: {
|
|
792
|
+
'Content-Type': 'application/json',
|
|
793
|
+
'X-CSRFToken': getCsrfToken()
|
|
794
|
+
},
|
|
795
|
+
body: JSON.stringify({
|
|
796
|
+
policy_id: policyId,
|
|
797
|
+
name: trimmedName
|
|
798
|
+
})
|
|
799
|
+
});
|
|
800
|
+
|
|
801
|
+
const data = await response.json();
|
|
802
|
+
|
|
803
|
+
if (data.success) {
|
|
804
|
+
showToast(data.message || 'Enrollment token created successfully', 'success');
|
|
805
|
+
|
|
806
|
+
// Reload enrollment tokens
|
|
807
|
+
await loadEnrollmentTokens(policyId);
|
|
808
|
+
|
|
809
|
+
// Select the newly created token (it will be the last one added)
|
|
810
|
+
// We need to find it by name since we don't have the ID in the response
|
|
811
|
+
const options = Array.from(this.options);
|
|
812
|
+
const newTokenOption = options.find(opt => opt.textContent === trimmedName);
|
|
813
|
+
if (newTokenOption) {
|
|
814
|
+
this.value = newTokenOption.value;
|
|
815
|
+
this.dispatchEvent(new Event('change'));
|
|
816
|
+
}
|
|
817
|
+
} else {
|
|
818
|
+
showToast(data.error || 'Failed to create enrollment token', 'error');
|
|
819
|
+
// Reset to empty selection
|
|
820
|
+
this.value = '';
|
|
821
|
+
}
|
|
822
|
+
} catch (error) {
|
|
823
|
+
console.error('Error creating enrollment token:', error);
|
|
824
|
+
showToast('Failed to create enrollment token: ' + error.message, 'error');
|
|
825
|
+
// Reset to empty selection
|
|
826
|
+
this.value = '';
|
|
827
|
+
}
|
|
828
|
+
} else {
|
|
829
|
+
// User cancelled, reset to empty selection
|
|
830
|
+
this.value = '';
|
|
831
|
+
}
|
|
832
|
+
} else {
|
|
833
|
+
const selectedOption = this.options[this.selectedIndex];
|
|
834
|
+
const encodedToken = selectedOption.dataset.encodedToken;
|
|
835
|
+
|
|
836
|
+
if (encodedToken && hasSelectedAgentPolicy()) {
|
|
837
|
+
// Update Linux commands with the selected enrollment token
|
|
838
|
+
updateLinuxCommands(encodedToken);
|
|
839
|
+
|
|
840
|
+
// Show Linux commands section
|
|
841
|
+
const linuxCommandsSection = document.getElementById('linuxCommandsSection');
|
|
842
|
+
if (linuxCommandsSection) {
|
|
843
|
+
linuxCommandsSection.classList.remove('hidden');
|
|
844
|
+
}
|
|
845
|
+
} else {
|
|
846
|
+
// Hide Linux commands section when no token is selected
|
|
847
|
+
const linuxCommandsSection = document.getElementById('linuxCommandsSection');
|
|
848
|
+
if (linuxCommandsSection) {
|
|
849
|
+
linuxCommandsSection.classList.add('hidden');
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
function selectedAgentPolicyMeta() {
|
|
857
|
+
const agentPolicySelect = document.getElementById('agentPolicy');
|
|
858
|
+
if (!agentPolicySelect || agentPolicySelect.selectedIndex < 0) {
|
|
859
|
+
return { policyType: 'DEFAULT', logstashSource: 'SYSTEM' };
|
|
860
|
+
}
|
|
861
|
+
const opt = agentPolicySelect.options[agentPolicySelect.selectedIndex];
|
|
862
|
+
return {
|
|
863
|
+
policyType: (opt.dataset.policyType || 'DEFAULT').toUpperCase(),
|
|
864
|
+
logstashSource: (opt.dataset.logstashSource || 'SYSTEM').toUpperCase(),
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
/** Whether "Install Logstash" belongs in the enroll snippet for the selected policy. */
|
|
869
|
+
function shouldOfferInstallLogstash() {
|
|
870
|
+
const { policyType, logstashSource } = selectedAgentPolicyMeta();
|
|
871
|
+
const pt = policyType === 'DEFAULT' ? 'PACKAGED' : policyType;
|
|
872
|
+
if (pt === 'EMBEDDED') {
|
|
873
|
+
return false;
|
|
874
|
+
}
|
|
875
|
+
// MANAGED: the agent installs and manages its own Logstash; no manual package install
|
|
876
|
+
if (pt === 'MANAGED') {
|
|
877
|
+
return false;
|
|
878
|
+
}
|
|
879
|
+
// VERSION source downloads Logstash; OS package install is not used
|
|
880
|
+
if (pt === 'SIMULATE' && logstashSource === 'VERSION') {
|
|
881
|
+
return false;
|
|
882
|
+
}
|
|
883
|
+
return true;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
/** True once the user has explicitly picked a real policy (not the placeholder or "+ Add"). */
|
|
887
|
+
function hasSelectedAgentPolicy() {
|
|
888
|
+
const select = document.getElementById('agentPolicy');
|
|
889
|
+
return !!(select && select.value && select.value !== 'add_new');
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
/**
|
|
893
|
+
* Gate the enrollment token and install commands behind an explicit policy choice.
|
|
894
|
+
*
|
|
895
|
+
* Hidden until a policy is selected so users cannot copy a command block without
|
|
896
|
+
* first deciding which policy the agent will enroll into. Embedded policies are
|
|
897
|
+
* never enrolled via this modal (filtered from dropdown); handled defensively.
|
|
898
|
+
*/
|
|
899
|
+
function syncEnrollmentGate() {
|
|
900
|
+
const { policyType } = selectedAgentPolicyMeta();
|
|
901
|
+
const showEnroll = hasSelectedAgentPolicy() && policyType !== 'EMBEDDED';
|
|
902
|
+
const enrollmentTokenSection = document.getElementById('enrollmentTokenSection');
|
|
903
|
+
const linuxCommandsSection = document.getElementById('linuxCommandsSection');
|
|
904
|
+
if (enrollmentTokenSection) {
|
|
905
|
+
enrollmentTokenSection.classList.toggle('hidden', !showEnroll);
|
|
906
|
+
}
|
|
907
|
+
if (linuxCommandsSection && !showEnroll) {
|
|
908
|
+
linuxCommandsSection.classList.add('hidden');
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
/** Reset the agent enrollment form to its initial "choose a policy" state. */
|
|
913
|
+
window.resetAgentEnrollSelection = function() {
|
|
914
|
+
const select = document.getElementById('agentPolicy');
|
|
915
|
+
const tokenSelect = document.getElementById('enrollmentToken');
|
|
916
|
+
if (select) select.value = '';
|
|
917
|
+
if (tokenSelect) tokenSelect.innerHTML = '<option value="">Select a token...</option><option value="add_new" class="font-bold text-primary">+ Add Token</option>';
|
|
918
|
+
syncEnrollmentGate();
|
|
919
|
+
};
|
|
920
|
+
|
|
921
|
+
function syncInstallLogstashVisibility() {
|
|
922
|
+
const row = document.getElementById('installLogstashRow');
|
|
923
|
+
const checkbox = document.getElementById('installLogstashCheckbox');
|
|
924
|
+
const pkgSection = document.getElementById('packageManagerSection');
|
|
925
|
+
const hint = document.getElementById('installLogstashHint');
|
|
926
|
+
const offer = shouldOfferInstallLogstash();
|
|
927
|
+
const managedNotice = document.getElementById('managedLogstashNotice');
|
|
928
|
+
if (managedNotice) {
|
|
929
|
+
const { policyType } = selectedAgentPolicyMeta();
|
|
930
|
+
managedNotice.classList.toggle('hidden', !(hasSelectedAgentPolicy() && policyType === 'MANAGED'));
|
|
931
|
+
}
|
|
932
|
+
if (row) {
|
|
933
|
+
if (offer) {
|
|
934
|
+
row.classList.remove('hidden');
|
|
935
|
+
} else {
|
|
936
|
+
row.classList.add('hidden');
|
|
937
|
+
if (checkbox) checkbox.checked = false;
|
|
938
|
+
if (pkgSection) pkgSection.classList.add('hidden');
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
if (hint) {
|
|
942
|
+
if (!offer) {
|
|
943
|
+
const agentPolicySelect = document.getElementById('agentPolicy');
|
|
944
|
+
const opt = agentPolicySelect && agentPolicySelect.options[agentPolicySelect.selectedIndex];
|
|
945
|
+
const policyType = (opt && opt.dataset.policyType || '').toUpperCase();
|
|
946
|
+
const logstashSource = (opt && opt.dataset.logstashSource || '').toUpperCase();
|
|
947
|
+
if (policyType === 'EMBEDDED') {
|
|
948
|
+
hint.textContent = 'Embedded agents use the container Logstash; package install is not used.';
|
|
949
|
+
} else if (policyType === 'SIMULATE' && logstashSource === 'VERSION') {
|
|
950
|
+
hint.textContent = 'This Simulate policy uses a VERSION Logstash binary (agent download), not the OS package.';
|
|
951
|
+
} else {
|
|
952
|
+
hint.textContent = '';
|
|
953
|
+
}
|
|
954
|
+
// Keep hint only if we show something when row is hidden — optional, leave hidden with row
|
|
955
|
+
hint.classList.add('hidden');
|
|
956
|
+
} else {
|
|
957
|
+
hint.classList.add('hidden');
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
// Function to update Linux commands with enrollment token
|
|
963
|
+
function updateLinuxCommands(encodedToken) {
|
|
964
|
+
const linuxCommandsElement = document.getElementById('linuxCommands');
|
|
965
|
+
const localhostWarning = document.getElementById('localhostWarning');
|
|
966
|
+
const installLogstashCheckbox = document.getElementById('installLogstashCheckbox');
|
|
967
|
+
const packageManagerRadio = document.querySelector('input[name="package_manager"]:checked');
|
|
968
|
+
const customUrlInput = document.getElementById('customLogstashUIUrl');
|
|
969
|
+
|
|
970
|
+
syncInstallLogstashVisibility();
|
|
971
|
+
|
|
972
|
+
if (linuxCommandsElement) {
|
|
973
|
+
// Get the URL to use - custom input takes precedence over browser URL
|
|
974
|
+
const browserUrl = window.location.origin;
|
|
975
|
+
const customUrl = customUrlInput ? customUrlInput.value.trim() : '';
|
|
976
|
+
const currentUrl = customUrl || browserUrl;
|
|
977
|
+
|
|
978
|
+
// Check if the URL contains localhost or 127.0.0.1
|
|
979
|
+
const isLocalhost = browserUrl.includes('localhost') || browserUrl.includes('127.0.0.1');
|
|
980
|
+
|
|
981
|
+
// Show or hide the localhost warning
|
|
982
|
+
if (localhostWarning) {
|
|
983
|
+
if (isLocalhost) {
|
|
984
|
+
localhostWarning.classList.remove('hidden');
|
|
985
|
+
} else {
|
|
986
|
+
localhostWarning.classList.add('hidden');
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
// Build the commands
|
|
991
|
+
let commands = '';
|
|
992
|
+
|
|
993
|
+
// Add Logstash installation commands if checkbox is checked and policy allows it
|
|
994
|
+
if (
|
|
995
|
+
shouldOfferInstallLogstash() &&
|
|
996
|
+
installLogstashCheckbox &&
|
|
997
|
+
installLogstashCheckbox.checked
|
|
998
|
+
) {
|
|
999
|
+
const packageManager = packageManagerRadio ? packageManagerRadio.value : 'apt';
|
|
1000
|
+
|
|
1001
|
+
if (packageManager === 'apt') {
|
|
1002
|
+
commands += `# Install Logstash
|
|
1003
|
+
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elastic-keyring.gpg
|
|
1004
|
+
sudo apt-get install apt-transport-https -y
|
|
1005
|
+
echo "deb [signed-by=/usr/share/keyrings/elastic-keyring.gpg] https://artifacts.elastic.co/packages/9.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-9.x.list
|
|
1006
|
+
sudo apt-get update -y && sudo apt-get install logstash -y
|
|
1007
|
+
sudo systemctl enable logstash
|
|
1008
|
+
|
|
1009
|
+
`;
|
|
1010
|
+
} else if (packageManager === 'yum') {
|
|
1011
|
+
commands += `# Install Logstash
|
|
1012
|
+
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
|
|
1013
|
+
echo '[logstash-9.x]
|
|
1014
|
+
name=Elastic repository for 9.x packages
|
|
1015
|
+
baseurl=https://artifacts.elastic.co/packages/9.x/yum
|
|
1016
|
+
gpgcheck=1
|
|
1017
|
+
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
|
|
1018
|
+
enabled=1
|
|
1019
|
+
autorefresh=1
|
|
1020
|
+
type=rpm-md' | sudo tee /etc/yum.repos.d/logstash.repo
|
|
1021
|
+
sudo yum install logstash -y
|
|
1022
|
+
sudo systemctl enable logstash
|
|
1023
|
+
|
|
1024
|
+
`;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
// Install is a full deploy: agent unit is enabled+started by install.
|
|
1029
|
+
// Distro Logstash is enabled only (never bounced) for Packaged/live hosts.
|
|
1030
|
+
const { policyType, logstashSource } = selectedAgentPolicyMeta();
|
|
1031
|
+
const pt = policyType === 'DEFAULT' ? 'PACKAGED' : policyType;
|
|
1032
|
+
let day2 = `# After install the packaged agent service is already running.
|
|
1033
|
+
# Day-2 (packaged only — does not stop managed/simulate instances):
|
|
1034
|
+
# sudo systemctl status logstash-agent
|
|
1035
|
+
# sudo systemctl stop logstash-agent
|
|
1036
|
+
# sudo systemctl start logstash-agent
|
|
1037
|
+
# sudo journalctl -u logstash-agent -f
|
|
1038
|
+
# Host map (all roles): logstash-agent list-instances
|
|
1039
|
+
# State: /var/lib/logstash-agent Config: /etc/logstash-agent/logstash-agent.yml`;
|
|
1040
|
+
if (pt === 'SIMULATE') {
|
|
1041
|
+
day2 = `# After install the simulate agent unit is enabled and started
|
|
1042
|
+
# (instance number N is shown in install output / UI connection).
|
|
1043
|
+
# Coexists with packaged logstash-agent.service on the same host.
|
|
1044
|
+
# Day-2 (this instance only — replace N):
|
|
1045
|
+
# sudo systemctl status lsagent-simulate@N
|
|
1046
|
+
# sudo systemctl stop lsagent-simulate@N
|
|
1047
|
+
# sudo systemctl start lsagent-simulate@N
|
|
1048
|
+
# sudo journalctl -u lsagent-simulate@N -f
|
|
1049
|
+
# sudo systemctl status ls-simulate@N
|
|
1050
|
+
# State/config: /opt/logstash-agent/simulate-N/{state,logstash-agent.yml}
|
|
1051
|
+
# Host map: logstash-agent list-instances`;
|
|
1052
|
+
} else if (pt === 'MANAGED') {
|
|
1053
|
+
day2 = `# After install the managed agent unit is enabled and started
|
|
1054
|
+
# (instance number N is shown in install output / UI connection).
|
|
1055
|
+
# Coexists with packaged logstash-agent.service on the same host.
|
|
1056
|
+
# Day-2 (this instance only — replace N):
|
|
1057
|
+
# sudo systemctl status logstash-agent@N
|
|
1058
|
+
# sudo systemctl stop logstash-agent@N
|
|
1059
|
+
# sudo systemctl start logstash-agent@N
|
|
1060
|
+
# sudo journalctl -u logstash-agent@N -f
|
|
1061
|
+
# # or: sudo logstash-agent-ctl status logstash-agent@N
|
|
1062
|
+
# sudo systemctl status logstash-managed@N
|
|
1063
|
+
# State/config: /opt/logstash-agent/managed-N/{state,logstash-agent.yml}
|
|
1064
|
+
# Host map: logstash-agent list-instances
|
|
1065
|
+
# Drop only this instance: sudo logstash-agent uninstall --instance managed-N`;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
commands += `# Install LogstashAgent
|
|
1069
|
+
curl -LO https://github.com/elastic/LogstashAgent/releases/download/v{{ preferred_agent_version }}/logstash-agent-linux-amd64.tar.gz
|
|
1070
|
+
tar -xzf logstash-agent-linux-amd64.tar.gz
|
|
1071
|
+
sudo ./logstash-agent/logstash-agent install --enroll ${encodedToken} --logstash-ui-url ${currentUrl} --yes
|
|
1072
|
+
|
|
1073
|
+
${day2}`;
|
|
1074
|
+
|
|
1075
|
+
// Update the commands
|
|
1076
|
+
linuxCommandsElement.innerHTML = `<code>${commands}</code>`;
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
// Function to update Linux commands when custom URL changes
|
|
1081
|
+
function updateLinuxCommandsUrl() {
|
|
1082
|
+
// Get the currently selected enrollment token
|
|
1083
|
+
const enrollmentTokenSelect = document.getElementById('enrollmentToken');
|
|
1084
|
+
if (enrollmentTokenSelect && enrollmentTokenSelect.value && enrollmentTokenSelect.value !== 'add_new') {
|
|
1085
|
+
const selectedOption = enrollmentTokenSelect.options[enrollmentTokenSelect.selectedIndex];
|
|
1086
|
+
const encodedToken = selectedOption.dataset.encodedToken;
|
|
1087
|
+
if (encodedToken) {
|
|
1088
|
+
updateLinuxCommands(encodedToken);
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
// Function to generate enrollment token - make it globally accessible
|
|
1094
|
+
window.generateEnrollmentToken = async function(policyName) {
|
|
1095
|
+
try {
|
|
1096
|
+
const response = await fetch('/ConnectionManager/GenerateEnrollmentToken/', {
|
|
1097
|
+
method: 'POST',
|
|
1098
|
+
headers: {
|
|
1099
|
+
'Content-Type': 'application/json',
|
|
1100
|
+
'X-CSRFToken': getCsrfToken()
|
|
1101
|
+
},
|
|
1102
|
+
body: JSON.stringify({
|
|
1103
|
+
policy_name: policyName
|
|
1104
|
+
})
|
|
1105
|
+
});
|
|
1106
|
+
|
|
1107
|
+
const data = await response.json();
|
|
1108
|
+
|
|
1109
|
+
if (data.success) {
|
|
1110
|
+
// Update the enrollment token in the installation commands
|
|
1111
|
+
updateEnrollmentToken(data.enrollment_token);
|
|
1112
|
+
} else {
|
|
1113
|
+
showToast(data.error || 'Failed to generate enrollment token', 'error');
|
|
1114
|
+
}
|
|
1115
|
+
} catch (error) {
|
|
1116
|
+
console.error('Error generating enrollment token:', error);
|
|
1117
|
+
showToast('Failed to generate enrollment token: ' + error.message, 'error');
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
// Function to update enrollment token in installation commands
|
|
1122
|
+
function updateEnrollmentToken(token) {
|
|
1123
|
+
updateLinuxCommands(token);
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
// Helper function to get CSRF token
|
|
1127
|
+
function getCsrfToken() {
|
|
1128
|
+
const name = 'csrftoken';
|
|
1129
|
+
let cookieValue = null;
|
|
1130
|
+
if (document.cookie && document.cookie !== '') {
|
|
1131
|
+
const cookies = document.cookie.split(';');
|
|
1132
|
+
for (let i = 0; i < cookies.length; i++) {
|
|
1133
|
+
const cookie = cookies[i].trim();
|
|
1134
|
+
if (cookie.substring(0, name.length + 1) === (name + '=')) {
|
|
1135
|
+
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
|
1136
|
+
break;
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
return cookieValue;
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
// Toggle between Cloud ID and Node URL fields (for centralized connections)
|
|
1144
|
+
// Also clear the values of whichever field group is being hidden so that
|
|
1145
|
+
// stale data is not silently included in the POST payload.
|
|
1146
|
+
document.querySelectorAll('input[name="connection_mode"]').forEach(radio => {
|
|
1147
|
+
radio.addEventListener('change', function() {
|
|
1148
|
+
if (this.value === 'cloud') {
|
|
1149
|
+
document.getElementById('cloudIdField').classList.remove('hidden');
|
|
1150
|
+
document.getElementById('nodeUrlField').classList.add('hidden');
|
|
1151
|
+
// Clear the now-hidden URL fields
|
|
1152
|
+
const hostInput = document.querySelector('[name="host"]');
|
|
1153
|
+
const portInput = document.querySelector('[name="port"]');
|
|
1154
|
+
if (hostInput) hostInput.value = '';
|
|
1155
|
+
if (portInput) portInput.value = '';
|
|
1156
|
+
} else {
|
|
1157
|
+
document.getElementById('cloudIdField').classList.add('hidden');
|
|
1158
|
+
document.getElementById('nodeUrlField').classList.remove('hidden');
|
|
1159
|
+
// Clear the now-hidden Cloud ID field
|
|
1160
|
+
const cloudIdInput = document.querySelector('[name="cloud_id"]');
|
|
1161
|
+
if (cloudIdInput) cloudIdInput.value = '';
|
|
1162
|
+
}
|
|
1163
|
+
});
|
|
1164
|
+
});
|
|
1165
|
+
|
|
1166
|
+
|
|
1167
|
+
|
|
1168
|
+
// Toggle between Basic Auth and API Key fields (for centralized connections)
|
|
1169
|
+
// Also clear the values of whichever field group is being hidden so that
|
|
1170
|
+
// stale credentials are not silently included in the POST payload.
|
|
1171
|
+
document.querySelectorAll('input[name="auth_type"]').forEach(radio => {
|
|
1172
|
+
radio.addEventListener('change', function() {
|
|
1173
|
+
document.getElementById('basicAuthFields').classList.toggle('hidden', this.value !== 'basic');
|
|
1174
|
+
document.getElementById('apiKeyField').classList.toggle('hidden', this.value !== 'apiKey');
|
|
1175
|
+
if (this.value === 'basic') {
|
|
1176
|
+
// Clear the now-hidden API key field
|
|
1177
|
+
const apiKeyInput = document.querySelector('[name="api_key"]');
|
|
1178
|
+
if (apiKeyInput) apiKeyInput.value = '';
|
|
1179
|
+
} else {
|
|
1180
|
+
// Clear the now-hidden username / password fields
|
|
1181
|
+
const usernameInput = document.querySelector('[name="username"]');
|
|
1182
|
+
const passwordInput = document.querySelector('[name="password"]');
|
|
1183
|
+
if (usernameInput) usernameInput.value = '';
|
|
1184
|
+
if (passwordInput) passwordInput.value = '';
|
|
1185
|
+
}
|
|
1186
|
+
});
|
|
1187
|
+
});
|
|
1188
|
+
|
|
1189
|
+
// Parse URL in host field to extract scheme and port
|
|
1190
|
+
const hostInput = document.querySelector('input[name="host"]');
|
|
1191
|
+
const portInput = document.querySelector('input[name="port"]');
|
|
1192
|
+
|
|
1193
|
+
if (hostInput && portInput) {
|
|
1194
|
+
hostInput.addEventListener('blur', function() {
|
|
1195
|
+
let url = this.value.trim();
|
|
1196
|
+
|
|
1197
|
+
// Only process if in URL mode (not Cloud ID mode)
|
|
1198
|
+
if (!document.getElementById('nodeUrlField').classList.contains('hidden')) {
|
|
1199
|
+
// Check if URL has a scheme
|
|
1200
|
+
if (url && !url.match(/^https?:\/\//i)) {
|
|
1201
|
+
// No scheme provided, show error
|
|
1202
|
+
showToast('Please include http:// or https:// in the URL', 'warning');
|
|
1203
|
+
return;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
if (url.match(/^https?:\/\//i)) {
|
|
1207
|
+
try {
|
|
1208
|
+
const urlObj = new URL(url);
|
|
1209
|
+
|
|
1210
|
+
// Extract hostname (without port)
|
|
1211
|
+
const hostname = urlObj.hostname;
|
|
1212
|
+
|
|
1213
|
+
// Extract port if present, otherwise use default based on scheme
|
|
1214
|
+
let port = urlObj.port;
|
|
1215
|
+
if (!port) {
|
|
1216
|
+
port = urlObj.protocol === 'https:' ? '443' : '80';
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
// Update the host field with just the scheme and hostname
|
|
1220
|
+
this.value = urlObj.protocol + '//' + hostname;
|
|
1221
|
+
|
|
1222
|
+
// Update the port field
|
|
1223
|
+
portInput.value = port;
|
|
1224
|
+
|
|
1225
|
+
} catch (e) {
|
|
1226
|
+
showToast('Invalid URL format. Please use http://hostname or https://hostname', 'error');
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
});
|
|
1231
|
+
|
|
1232
|
+
// Also validate on form submit
|
|
1233
|
+
const connectionForm = document.getElementById('connectionForm');
|
|
1234
|
+
connectionForm.addEventListener('submit', function(e) {
|
|
1235
|
+
const connectionMode = document.querySelector('input[name="connection_mode"]:checked');
|
|
1236
|
+
|
|
1237
|
+
// Only validate if using Node URL mode (not Cloud ID)
|
|
1238
|
+
if (connectionMode && connectionMode.value === 'url') {
|
|
1239
|
+
const hostValue = hostInput.value.trim();
|
|
1240
|
+
|
|
1241
|
+
if (hostValue && !hostValue.match(/^https?:\/\//i)) {
|
|
1242
|
+
e.preventDefault();
|
|
1243
|
+
e.stopPropagation();
|
|
1244
|
+
showToast('Elastic Node URL must start with http:// or https://', 'error');
|
|
1245
|
+
hostInput.focus();
|
|
1246
|
+
return false;
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
// Copy to clipboard function for agent installation commands
|
|
1253
|
+
function copyToClipboard(elementId, event) {
|
|
1254
|
+
const element = document.getElementById(elementId);
|
|
1255
|
+
const copyButton = event.target;
|
|
1256
|
+
|
|
1257
|
+
if (!element) {
|
|
1258
|
+
console.error('Could not find element:', elementId);
|
|
1259
|
+
return;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
const text = element.textContent;
|
|
1263
|
+
|
|
1264
|
+
// Function to update button state on success
|
|
1265
|
+
function onSuccess() {
|
|
1266
|
+
const originalText = copyButton.textContent;
|
|
1267
|
+
copyButton.textContent = 'Copied!';
|
|
1268
|
+
copyButton.classList.remove('text-blue-400', 'hover:text-blue-300');
|
|
1269
|
+
copyButton.classList.add('text-green-400', 'hover:text-green-300');
|
|
1270
|
+
|
|
1271
|
+
setTimeout(function() {
|
|
1272
|
+
copyButton.textContent = originalText;
|
|
1273
|
+
copyButton.classList.remove('text-green-400', 'hover:text-green-300');
|
|
1274
|
+
copyButton.classList.add('text-blue-400', 'hover:text-blue-300');
|
|
1275
|
+
}, 2000);
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
// Function to update button state on failure
|
|
1279
|
+
function onFailure(err) {
|
|
1280
|
+
console.error('Failed to copy text: ', err);
|
|
1281
|
+
copyButton.textContent = 'Failed!';
|
|
1282
|
+
copyButton.classList.remove('text-blue-400', 'hover:text-blue-300');
|
|
1283
|
+
copyButton.classList.add('text-red-400', 'hover:text-red-300');
|
|
1284
|
+
|
|
1285
|
+
setTimeout(function() {
|
|
1286
|
+
copyButton.textContent = 'Copy';
|
|
1287
|
+
copyButton.classList.remove('text-red-400', 'hover:text-red-300');
|
|
1288
|
+
copyButton.classList.add('text-blue-400', 'hover:text-blue-300');
|
|
1289
|
+
}, 2000);
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
// Try modern Clipboard API first (requires HTTPS or localhost)
|
|
1293
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
1294
|
+
navigator.clipboard.writeText(text).then(onSuccess, onFailure);
|
|
1295
|
+
} else {
|
|
1296
|
+
// Fallback for non-secure contexts (HTTP)
|
|
1297
|
+
try {
|
|
1298
|
+
const textarea = document.createElement('textarea');
|
|
1299
|
+
textarea.value = text;
|
|
1300
|
+
textarea.style.position = 'fixed';
|
|
1301
|
+
textarea.style.opacity = '0';
|
|
1302
|
+
document.body.appendChild(textarea);
|
|
1303
|
+
textarea.select();
|
|
1304
|
+
const successful = document.execCommand('copy');
|
|
1305
|
+
document.body.removeChild(textarea);
|
|
1306
|
+
|
|
1307
|
+
if (successful) {
|
|
1308
|
+
onSuccess();
|
|
1309
|
+
} else {
|
|
1310
|
+
onFailure(new Error('execCommand copy failed'));
|
|
1311
|
+
}
|
|
1312
|
+
} catch (err) {
|
|
1313
|
+
onFailure(err);
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
// Handle Install Logstash checkbox change
|
|
1319
|
+
const installLogstashCheckbox = document.getElementById('installLogstashCheckbox');
|
|
1320
|
+
const packageManagerSection = document.getElementById('packageManagerSection');
|
|
1321
|
+
|
|
1322
|
+
if (installLogstashCheckbox) {
|
|
1323
|
+
installLogstashCheckbox.addEventListener('change', function() {
|
|
1324
|
+
// Show/hide package manager selection
|
|
1325
|
+
if (packageManagerSection) {
|
|
1326
|
+
if (this.checked) {
|
|
1327
|
+
packageManagerSection.classList.remove('hidden');
|
|
1328
|
+
} else {
|
|
1329
|
+
packageManagerSection.classList.add('hidden');
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
// Update commands if enrollment token is already selected
|
|
1334
|
+
const enrollmentTokenSelect = document.getElementById('enrollmentToken');
|
|
1335
|
+
if (enrollmentTokenSelect && enrollmentTokenSelect.value && enrollmentTokenSelect.value !== 'add_new') {
|
|
1336
|
+
const selectedOption = enrollmentTokenSelect.options[enrollmentTokenSelect.selectedIndex];
|
|
1337
|
+
const encodedToken = selectedOption.dataset.encodedToken;
|
|
1338
|
+
if (encodedToken) {
|
|
1339
|
+
updateLinuxCommands(encodedToken);
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
});
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
// Handle package manager radio button changes
|
|
1346
|
+
const packageManagerRadios = document.querySelectorAll('input[name="package_manager"]');
|
|
1347
|
+
packageManagerRadios.forEach(radio => {
|
|
1348
|
+
radio.addEventListener('change', function() {
|
|
1349
|
+
// Update commands if enrollment token is already selected
|
|
1350
|
+
const enrollmentTokenSelect = document.getElementById('enrollmentToken');
|
|
1351
|
+
if (enrollmentTokenSelect && enrollmentTokenSelect.value && enrollmentTokenSelect.value !== 'add_new') {
|
|
1352
|
+
const selectedOption = enrollmentTokenSelect.options[enrollmentTokenSelect.selectedIndex];
|
|
1353
|
+
const encodedToken = selectedOption.dataset.encodedToken;
|
|
1354
|
+
if (encodedToken) {
|
|
1355
|
+
updateLinuxCommands(encodedToken);
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
});
|
|
1359
|
+
});
|
|
1360
|
+
|
|
1361
|
+
</script>
|