├── .gitignore ├── apm └── apm-server.yml ├── app ├── .docker │ └── entrypoint.sh ├── .gitignore ├── Dockerfile ├── codeprogress │ ├── __init__.py │ ├── asgi.py │ ├── logger.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py ├── db.sqlite3 ├── docker-compose.yaml ├── exemplo │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── migrations │ │ ├── 0001_initial.py │ │ └── __init__.py │ ├── models.py │ ├── templates │ │ └── exemplo │ │ │ └── index.html │ ├── tests.py │ ├── urls.py │ └── views.py ├── manage.py └── requirements.txt ├── beats ├── heartbeat │ └── heartbeat.yml └── metric │ └── metricbeat.yml ├── docker-compose.yaml └── nginx ├── Dockerfile ├── default.conf ├── entrypoint.sh └── filebeat.yml /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/* 2 | app/.idea/* 3 | app/.docker/pgdata 4 | app/*.pyc 5 | app/__pycache__ 6 | elasticsearch_data/ -------------------------------------------------------------------------------- /apm/apm-server.yml: -------------------------------------------------------------------------------- 1 | ######################### APM Server Configuration ######################### 2 | 3 | ################################ APM Server ################################ 4 | 5 | apm-server: 6 | # Defines the host and port the server is listening on. Use "unix:/path/to.sock" to listen on a unix domain socket. 7 | host: "0.0.0.0:8200" 8 | 9 | # Maximum permitted size in bytes of a request's header accepted by the server to be processed. 10 | #max_header_size: 1048576 11 | 12 | # Maximum amount of time to wait for the next incoming request before underlying connection is closed. 13 | #idle_timeout: 45s 14 | 15 | # Maximum permitted duration for reading an entire request. 16 | #read_timeout: 30s 17 | 18 | # Maximum permitted duration for writing a response. 19 | #write_timeout: 30s 20 | 21 | # Maximum duration before releasing resources when shutting down the server. 22 | #shutdown_timeout: 5s 23 | 24 | # Maximum permitted size in bytes of an event accepted by the server to be processed. 25 | #max_event_size: 307200 26 | 27 | # Maximum number of new connections to accept simultaneously (0 means unlimited). 28 | #max_connections: 0 29 | 30 | # Custom HTTP headers to add to all HTTP responses, e.g. for security policy compliance. 31 | #response_headers: 32 | # X-My-Header: Contents of the header 33 | 34 | # If true (default), APM Server captures the IP of the instrumented service 35 | # or the IP and User Agent of the real user (RUM requests). 36 | #capture_personal_data: true 37 | 38 | # If specified, APM Server will record this value in events which have no service environment 39 | # defined, and add it to agent configuration queries to Kibana when none is specified in the 40 | # request from the agent. 41 | #default_service_environment: 42 | 43 | # Enable APM Server Golang expvar support (https://golang.org/pkg/expvar/). 44 | #expvar: 45 | #enabled: false 46 | 47 | # Url to expose expvar. 48 | #url: "/debug/vars" 49 | 50 | # A pipeline is a definition of processors applied to documents when ingesting them to Elasticsearch. 51 | # Using pipelines involves two steps: 52 | # (1) registering a pipeline 53 | # (2) applying a pipeline during data ingestion (see `output.elasticsearch.pipeline`) 54 | # 55 | # You can manually register a pipeline, or use this configuration option to ensure 56 | # the pipeline is loaded and registered at the configured Elasticsearch instances. 57 | # Find the default pipeline configuration at `ingest/pipeline/definition.json`. 58 | # Automatic pipeline registration requires the `output.elasticsearch` to be enabled and configured. 59 | #register.ingest.pipeline: 60 | # Registers APM pipeline definition in Elasticsearch on APM Server startup. Defaults to true. 61 | #enabled: true 62 | # Overwrites existing APM pipeline definition in Elasticsearch. Defaults to false. 63 | #overwrite: false 64 | 65 | 66 | #---------------------------- APM Server - Secure Communication with Agents ---------------------------- 67 | 68 | # Enable secure communication between APM agents and the server. By default ssl is disabled. 69 | #ssl: 70 | #enabled: false 71 | 72 | # Path to file containing the certificate for server authentication. 73 | # Needs to be configured when ssl is enabled. 74 | #certificate: '' 75 | 76 | # Path to file containing server certificate key. 77 | # Needs to be configured when ssl is enabled. 78 | #key: '' 79 | 80 | # Optional configuration options for ssl communication. 81 | 82 | # Passphrase for decrypting the Certificate Key. 83 | # It is recommended to use the provided keystore instead of entering the passphrase in plain text. 84 | #key_passphrase: '' 85 | 86 | # List of supported/valid protocol versions. By default TLS versions 1.1 up to 1.3 are enabled. 87 | #supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] 88 | 89 | # Configure cipher suites to be used for SSL connections. 90 | # Note that cipher suites are not configurable for TLS 1.3. 91 | #cipher_suites: [] 92 | 93 | # Configure curve types for ECDHE based cipher suites. 94 | #curve_types: [] 95 | 96 | # The APM Server endpoints can be secured by configuring a secret token or enabling the usage of API keys. Both 97 | # options can be enabled in parallel, allowing Elastic APM agents to chose whichever mechanism they support. 98 | # As soon as one of the options is enabled, requests without a valid token are denied by the server. An exception 99 | # to this are requests to any enabled RUM endpoint. RUM endpoints are generally not secured by any token. 100 | # 101 | # Configure authorization via a common `secret_token`. By default it is disabled. 102 | # Agents include the token in the following format: Authorization: Bearer . 103 | # It is recommended to use an authorization token in combination with SSL enabled, 104 | # and save the token in the apm-server keystore. 105 | #secret_token: 106 | 107 | # Enable API key authorization by setting enabled to true. By default API key support is disabled. 108 | # Agents include a valid API key in the following format: Authorization: ApiKey . 109 | # The key must be the base64 encoded representation of the API key's "id:key". 110 | #api_key: 111 | #enabled: false 112 | 113 | # Restrict how many unique API keys are allowed per minute. Should be set to at least the amount of different 114 | # API keys configured in your monitored services. Every unique API key triggers one request to Elasticsearch. 115 | #limit: 100 116 | 117 | # API keys need to be fetched from Elasticsearch. If nothing is configured, configuration settings from the 118 | # output section will be reused. 119 | # Note that configuration needs to point to a secured Elasticsearch cluster that is able to serve API key requests. 120 | #elasticsearch: 121 | #hosts: ["localhost:9200"] 122 | 123 | #protocol: "http" 124 | 125 | # Username and password are only needed for the apm-server apikey sub-command, and they are ignored otherwise 126 | # See `apm-server apikey --help` for details. 127 | #username: "elastic" 128 | #password: "changeme" 129 | 130 | # Optional HTTP Path. 131 | #path: "" 132 | 133 | # Proxy server url. 134 | #proxy_url: "" 135 | #proxy_disable: false 136 | 137 | # Configure http request timeout before failing an request to Elasticsearch. 138 | #timeout: 5s 139 | 140 | # Enable custom SSL settings. Set to false to ignore custom SSL settings for secure communication. 141 | #ssl.enabled: true 142 | 143 | # Optional SSL configuration options. SSL is off by default, change the `protocol` option if you want to enable `https`. 144 | # 145 | # Control the verification of Elasticsearch certificates. Valid values are: 146 | # * full, which verifies that the provided certificate is signed by a trusted 147 | # authority (CA) and also verifies that the server's hostname (or IP address) 148 | # matches the names identified within the certificate. 149 | # * strict, which verifies that the provided certificate is signed by a trusted 150 | # authority (CA) and also verifies that the server's hostname (or IP address) 151 | # matches the names identified within the certificate. If the Subject Alternative 152 | # Name is empty, it returns an error. 153 | # * certificate, which verifies that the provided certificate is signed by a 154 | # trusted authority (CA), but does not perform any hostname verification. 155 | # * none, which performs no verification of the server's certificate. This 156 | # mode disables many of the security benefits of SSL/TLS and should only be used 157 | # after very careful consideration. It is primarily intended as a temporary 158 | # diagnostic mechanism when attempting to resolve TLS errors; its use in 159 | # production environments is strongly discouraged. 160 | #ssl.verification_mode: full 161 | 162 | # List of supported/valid TLS versions. By default all TLS versions 1.0 up to 163 | # 1.2 are enabled. 164 | #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] 165 | 166 | # List of root certificates for HTTPS server verifications. 167 | #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] 168 | 169 | # Certificate for SSL client authentication. 170 | #ssl.certificate: "/etc/pki/client/cert.pem" 171 | 172 | # Client Certificate Key 173 | #ssl.key: "/etc/pki/client/cert.key" 174 | 175 | # Optional passphrase for decrypting the Certificate Key. 176 | # It is recommended to use the provided keystore instead of entering the passphrase in plain text. 177 | #ssl.key_passphrase: '' 178 | 179 | # Configure cipher suites to be used for SSL connections. 180 | #ssl.cipher_suites: [] 181 | 182 | # Configure curve types for ECDHE based cipher suites. 183 | #ssl.curve_types: [] 184 | 185 | # Configure what types of renegotiation are supported. Valid options are 186 | # never, once, and freely. Default is never. 187 | #ssl.renegotiation: never 188 | 189 | 190 | #---------------------------- APM Server - RUM Real User Monitoring ---------------------------- 191 | 192 | # Enable Real User Monitoring (RUM) Support. By default RUM is disabled. 193 | # RUM does not support token based authorization. Enabled RUM endpoints will not require any authorization 194 | # token configured for other endpoints. 195 | rum: 196 | enabled: true 197 | 198 | #event_rate: 199 | 200 | # Defines the maximum amount of events allowed to be sent to the APM Server RUM 201 | # endpoint per IP per second. Defaults to 300. 202 | #limit: 300 203 | 204 | # An LRU cache is used to keep a rate limit per IP for the most recently seen IPs. 205 | # This setting defines the number of unique IPs that can be tracked in the cache. 206 | # Sites with many concurrent clients should consider increasing this limit. Defaults to 1000. 207 | #lru_size: 1000 208 | 209 | #-- General RUM settings 210 | 211 | # A list of service names to allow, to limit service-specific indices and data streams 212 | # created for unauthenticated RUM events. 213 | # If the list is empty, any service name is allowed. 214 | #allow_service_names: [] 215 | 216 | # A list of permitted origins for real user monitoring. 217 | # User-agents will send an origin header that will be validated against this list. 218 | # An origin is made of a protocol scheme, host and port, without the url path. 219 | # Allowed origins in this setting can have * to match anything (eg.: http://*.example.com) 220 | # If an item in the list is a single '*', everything will be allowed. 221 | allow_origins: ['*'] 222 | 223 | # A list of Access-Control-Allow-Headers to allow RUM requests, in addition to "Content-Type", 224 | # "Content-Encoding", and "Accept" 225 | #allow_headers: [] 226 | 227 | # Custom HTTP headers to add to RUM responses, e.g. for security policy compliance. 228 | #response_headers: 229 | # X-My-Header: Contents of the header 230 | 231 | # Regexp to be matched against a stacktrace frame's `file_name` and `abs_path` attributes. 232 | # If the regexp matches, the stacktrace frame is considered to be a library frame. 233 | library_pattern: "node_modules|bower_components|~" 234 | 235 | # Regexp to be matched against a stacktrace frame's `file_name`. 236 | # If the regexp matches, the stacktrace frame is not used for calculating error groups. 237 | # The default pattern excludes stacktrace frames that have a filename starting with '/webpack' 238 | exclude_from_grouping: "^/webpack" 239 | 240 | # If a source map has previously been uploaded, source mapping is automatically applied. 241 | # to all error and transaction documents sent to the RUM endpoint. 242 | source_mapping: 243 | 244 | # Sourcemapping is enabled by default. 245 | enabled: true 246 | 247 | # Source maps are always fetched from Elasticsearch, by default using the output.elasticsearch configuration. 248 | # A different instance must be configured when using any other output. 249 | # This setting only affects sourcemap reads - the output determines where sourcemaps are written. 250 | elasticsearch: 251 | # Array of hosts to connect to. 252 | # Scheme and port can be left out and will be set to the default (`http` and `9200`). 253 | # In case you specify and additional path, the scheme is required: `http://localhost:9200/path`. 254 | # IPv6 addresses should always be defined as: `https://[2001:db8::1]:9200`. 255 | hosts: ["localhost:9200"] 256 | 257 | # Protocol - either `http` (default) or `https`. 258 | #protocol: "https" 259 | 260 | # Authentication credentials - either API key or username/password. 261 | #api_key: "id:api_key" 262 | username: "elastic" 263 | password: "changeme" 264 | 265 | # The `cache.expiration` determines how long a source map should be cached before fetching it again from Elasticsearch. 266 | # Note that values configured without a time unit will be interpreted as seconds. 267 | #cache: 268 | expiration: 5m 269 | 270 | # Source maps are stored in a separate index. 271 | # If the default index pattern for source maps at 'outputs.elasticsearch.indices' 272 | # is changed, a matching index pattern needs to be specified here. 273 | index_pattern: "apm-*-sourcemap*" 274 | 275 | #---------------------------- APM Server - Agent Configuration ---------------------------- 276 | # Directly specify agent configuration. If `agent_config` is set, agent 277 | # configuration under `kibana` will be ignored. 278 | # An agent's incoming configuration request will be matched to an 279 | # agent_config with the following precedence: 280 | # - service.name and service.environment match an agent_config 281 | # - service.name matches an agent_config, service.environment == "" 282 | # - service.environment matches an agent_config, service.name == "" 283 | # - an agent_config without a name or environment set 284 | # An empty result is is returned if no matching result is found. 285 | # agent_config: 286 | # - service.name: ten_percent 287 | # service.environment: production 288 | # config: 289 | # capture_body: off 290 | # capture_body: true 291 | # log_level: info 292 | # recording: true 293 | # transaction_sample_rate: 0.1 294 | # - service.name: frontend 295 | # agent.name: rum-js 296 | # config: 297 | # transaction_sample_rate: 0.1 298 | 299 | # When using APM agent configuration, information fetched from Kibana will be cached in memory for some time. 300 | # Specify cache key expiration via this setting. Default is 30 seconds. 301 | #agent.config.cache.expiration: 30s 302 | 303 | kibana: 304 | # For APM Agent configuration in Kibana, enabled must be true. 305 | enabled: true 306 | 307 | # Scheme and port can be left out and will be set to the default (`http` and `5601`). 308 | # In case you specify an additional path, the scheme is required: `http://localhost:5601/path`. 309 | # IPv6 addresses should always be defined as: `https://[2001:db8::1]:5601`. 310 | host: "kibana:5601" 311 | 312 | # Optional protocol and basic auth credentials. 313 | #protocol: "https" 314 | #username: "elastic" 315 | #password: "changeme" 316 | 317 | # Optional HTTP path. 318 | #path: "" 319 | 320 | # Enable custom SSL settings. Set to false to ignore custom SSL settings for secure communication. 321 | #ssl.enabled: true 322 | 323 | # Optional SSL configuration options. SSL is off by default, change the `protocol` option if you want to enable `https`. 324 | # 325 | # Control the verification of Kibana certificates. Valid values are: 326 | # * full, which verifies that the provided certificate is signed by a trusted 327 | # authority (CA) and also verifies that the server's hostname (or IP address) 328 | # matches the names identified within the certificate. 329 | # * strict, which verifies that the provided certificate is signed by a trusted 330 | # authority (CA) and also verifies that the server's hostname (or IP address) 331 | # matches the names identified within the certificate. If the Subject Alternative 332 | # Name is empty, it returns an error. 333 | # * certificate, which verifies that the provided certificate is signed by a 334 | # trusted authority (CA), but does not perform any hostname verification. 335 | # * none, which performs no verification of the server's certificate. This 336 | # mode disables many of the security benefits of SSL/TLS and should only be used 337 | # after very careful consideration. It is primarily intended as a temporary 338 | # diagnostic mechanism when attempting to resolve TLS errors; its use in 339 | # production environments is strongly discouraged. 340 | #ssl.verification_mode: full 341 | 342 | # List of supported/valid TLS versions. By default all TLS versions 1.0 up to 343 | # 1.2 are enabled. 344 | #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] 345 | 346 | # List of root certificates for HTTPS server verifications. 347 | #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] 348 | 349 | # Certificate for SSL client authentication. 350 | #ssl.certificate: "/etc/pki/client/cert.pem" 351 | 352 | # Client Certificate Key 353 | #ssl.key: "/etc/pki/client/cert.key" 354 | 355 | # Optional passphrase for decrypting the Certificate Key. 356 | # It is recommended to use the provided keystore instead of entering the passphrase in plain text. 357 | #ssl.key_passphrase: '' 358 | 359 | # Configure cipher suites to be used for SSL connections. 360 | #ssl.cipher_suites: [] 361 | 362 | # Configure curve types for ECDHE based cipher suites. 363 | #ssl.curve_types: [] 364 | 365 | #---------------------------- APM Server - ILM Index Lifecycle Management ---------------------------- 366 | 367 | #ilm: 368 | # Supported values are `auto`, `true` and `false`. 369 | # `true`: Make use of Elasticsearch's Index Lifecycle Management (ILM) for APM indices. If no Elasticsearch output is 370 | # configured or the configured instance does not support ILM, APM Server cannot apply ILM and must create 371 | # unmanaged indices instead. 372 | # `false`: APM Server does not make use of ILM in Elasticsearch. 373 | # `auto`: If an Elasticsearch output is configured with default index and indices settings, and the configured 374 | # Elasticsearch instance supports ILM, `auto` will resolve to `true`. Otherwise `auto` will resolve to `false`. 375 | # Default value is `auto`. 376 | #enabled: "auto" 377 | 378 | #setup: 379 | # Only disable setup if you want to set up everything related to ILM on your own. 380 | # When setup is enabled, the APM Server creates: 381 | # - aliases and ILM policies if `apm-server.ilm.enabled` resolves to `true`. 382 | # - An ILM specific template per event type. This is required to map ILM aliases and policies to indices. In case 383 | # ILM is disabled, the templates will be created without any ILM settings. 384 | # Be aware that if you turn off setup, you need to manually manage event type specific templates on your own. 385 | # If you simply want to disable ILM, use the above setting, `apm-server.ilm.enabled`, instead. 386 | # Defaults to true. 387 | #enabled: true 388 | 389 | # Configure whether or not existing policies and ILM related templates should be updated. This needs to be 390 | # set to true when customizing your policies. 391 | # Defaults to false. 392 | #overwrite: false 393 | 394 | # Set `require_policy` to `false` when policies are set up outside of APM Server but referenced here. 395 | # Default value is `true`. 396 | #require_policy: true 397 | 398 | # Customized mappings will be merged with the default setup, so you only need to configure mappings for the 399 | # event types, policies, and index suffixes that you want to customize. 400 | # Indices are named in this way: `apm-%{[observer.version]}-%{[event.type]}-{index_suffix}`, 401 | # e.g., apm-7.9.0-span-custom*. The `index_suffix` is optional. 402 | # NOTE: When configuring an `index_suffix`, ensure that no previously set up templates conflict with the 403 | # newly configured ones. If an index matches multiple templates with the same order, the settings of 404 | # the templates will override each other. Any conflicts need to be cleaned up manually. 405 | # NOTE: When customizing `setup.template.name` and `setup.template.pattern`, ensure they still match the indices. 406 | #mapping: 407 | #- event_type: "error" 408 | # policy_name: "apm-rollover-30-days" 409 | # index_suffix: "" 410 | #- event_type: "span" 411 | # policy_name: "apm-rollover-30-days" 412 | # index_suffix: "" 413 | #- event_type: "transaction" 414 | # policy_name: "apm-rollover-30-days" 415 | # index_suffix: "" 416 | #- event_type: "metric" 417 | # policy_name: "apm-rollover-30-days" 418 | # index_suffix: "" 419 | 420 | # Configured policies are added to pre-defined default policies. 421 | # If a policy with the same name as a default policy is configured, the configured policy overwrites the default policy. 422 | #policies: 423 | #- name: "apm-rollover-30-days" 424 | #policy: 425 | #phases: 426 | #hot: 427 | #actions: 428 | #rollover: 429 | #max_size: "50gb" 430 | #max_age: "30d" 431 | #set_priority: 432 | #priority: 100 433 | #warm: 434 | #min_age: "30d" 435 | #actions: 436 | #set_priority: 437 | #priority: 50 438 | #readonly: {} 439 | 440 | 441 | 442 | #---------------------------- APM Server - Experimental Jaeger integration ---------------------------- 443 | 444 | # When enabling Jaeger integration, APM Server acts as Jaeger collector. It supports jaeger.thrift over HTTP 445 | # and gRPC. This is an experimental feature, use with care. 446 | # 447 | # WARNING: This configuration is deprecated, and will be removed in the 8.0 release. 448 | # 449 | # Jaeger gRPC is now served on the same port as Elastic APM agents, defined by the 450 | # "apm-server.host" configuration; it is implicitly enabled, and an agent tag called 451 | # "elastic-apm-auth" is required when auth is enabled. 452 | #jaeger: 453 | #grpc: 454 | # Set to true to enable the Jaeger gRPC collector service. 455 | #enabled: false 456 | 457 | # Defines the gRPC host and port the server is listening on. 458 | # Defaults to the standard Jaeger gRPC collector port 14250. 459 | #host: "0.0.0.0:14250" 460 | 461 | # Set to the name of a process tag to use for authorizing 462 | # Jaeger agents. 463 | # 464 | # The tag value should have the same format as an HTTP 465 | # Authorization header, i.e. "Bearer " or 466 | # "ApiKey ". 467 | # 468 | # By default (if the auth_tag value is empty), authorization 469 | # does not apply to Jaeger agents. 470 | #auth_tag: "" 471 | 472 | #http: 473 | # Set to true to enable the Jaeger HTTP collector endpoint. 474 | #enabled: false 475 | 476 | # Defines the HTTP host and port the server is listening on. 477 | # Defaults to the standard Jaeger HTTP collector port 14268. 478 | #host: "0.0.0.0:14268" 479 | 480 | #================================= General ================================= 481 | 482 | # Data is buffered in a memory queue before it is published to the configured output. 483 | # The memory queue will present all available events (up to the outputs 484 | # bulk_max_size) to the output, the moment the output is ready to serve 485 | # another batch of events. 486 | #queue: 487 | # Queue type by name (default 'mem'). 488 | #mem: 489 | # Max number of events the queue can buffer. 490 | #events: 4096 491 | 492 | # Hints the minimum number of events stored in the queue, 493 | # before providing a batch of events to the outputs. 494 | # The default value is set to 2048. 495 | # A value of 0 ensures events are immediately available 496 | # to be sent to the outputs. 497 | #flush.min_events: 2048 498 | 499 | # Maximum duration after which events are available to the outputs, 500 | # if the number of events stored in the queue is < `flush.min_events`. 501 | #flush.timeout: 1s 502 | 503 | # Sets the maximum number of CPUs that can be executing simultaneously. The 504 | # default is the number of logical CPUs available in the system. 505 | #max_procs: 506 | 507 | #================================= Template ================================= 508 | 509 | # A template is used to set the mapping in Elasticsearch. 510 | # By default template loading is enabled and the template is loaded. 511 | # These settings can be adjusted to load your own template or overwrite existing ones. 512 | 513 | # Set to false to disable template loading. 514 | #setup.template.enabled: true 515 | 516 | # Template name. By default the template name is "apm-%{[observer.version]}" 517 | # The template name and pattern has to be set in case the elasticsearch index pattern is modified. 518 | #setup.template.name: "apm-%{[observer.version]}" 519 | 520 | # Template pattern. By default the template pattern is "apm-%{[observer.version]}-*" to apply to the default index settings. 521 | # The first part is the version of apm-server and then -* is used to match all daily indices. 522 | # The template name and pattern has to be set in case the elasticsearch index pattern is modified. 523 | #setup.template.pattern: "apm-%{[observer.version]}-*" 524 | 525 | # Path to fields.yml file to generate the template. 526 | #setup.template.fields: "${path.config}/fields.yml" 527 | 528 | # Overwrite existing template. 529 | #setup.template.overwrite: false 530 | 531 | # Elasticsearch template settings. 532 | #setup.template.settings: 533 | 534 | # A dictionary of settings to place into the settings.index dictionary 535 | # of the Elasticsearch template. For more details, please check 536 | # https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html 537 | #index: 538 | #number_of_shards: 1 539 | #codec: best_compression 540 | #number_of_routing_shards: 30 541 | #mapping.total_fields.limit: 2000 542 | 543 | #============================= Elastic Cloud ============================= 544 | 545 | # These settings simplify using APM Server with the Elastic Cloud (https://cloud.elastic.co/). 546 | 547 | # The cloud.id setting overwrites the `output.elasticsearch.hosts` option. 548 | # You can find the `cloud.id` in the Elastic Cloud web UI. 549 | #cloud.id: 550 | 551 | # The cloud.auth setting overwrites the `output.elasticsearch.username` and 552 | # `output.elasticsearch.password` settings. The format is `:`. 553 | #cloud.auth: 554 | 555 | #================================ Outputs ================================= 556 | 557 | # Configure the output to use when sending the data collected by apm-server. 558 | 559 | #-------------------------- Elasticsearch output -------------------------- 560 | output.elasticsearch: 561 | # Array of hosts to connect to. 562 | # Scheme and port can be left out and will be set to the default (`http` and `9200`). 563 | # In case you specify and additional path, the scheme is required: `http://localhost:9200/path`. 564 | # IPv6 addresses should always be defined as: `https://[2001:db8::1]:9200`. 565 | hosts: ["elasticsearch:9200"] 566 | 567 | # Boolean flag to enable or disable the output module. 568 | #enabled: true 569 | 570 | # Set gzip compression level. 571 | #compression_level: 0 572 | 573 | # Protocol - either `http` (default) or `https`. 574 | #protocol: "https" 575 | 576 | # Authentication credentials - either API key or username/password. 577 | #api_key: "id:api_key" 578 | #username: "elastic" 579 | #password: "changeme" 580 | 581 | # Dictionary of HTTP parameters to pass within the url with index operations. 582 | #parameters: 583 | #param1: value1 584 | #param2: value2 585 | 586 | # Number of workers per Elasticsearch host. 587 | #worker: 1 588 | 589 | # By using the configuration below, APM documents are stored to separate indices, 590 | # depending on their `processor.event`: 591 | # - error 592 | # - transaction 593 | # - span 594 | # - sourcemap 595 | # 596 | # The indices are all prefixed with `apm-%{[observer.version]}`. 597 | # To allow managing indices based on their age, all indices (except for sourcemaps) 598 | # end with the information of the day they got indexed. 599 | # e.g. "apm-7.3.0-transaction-2019.07.20" 600 | # 601 | # Be aware that you can only specify one Elasticsearch template. 602 | # If you modify the index patterns you must also update these configurations accordingly, 603 | # as they need to be aligned: 604 | # * `setup.template.name` 605 | # * `setup.template.pattern` 606 | #index: "apm-%{[observer.version]}-%{+yyyy.MM.dd}" 607 | #indices: 608 | # - index: "apm-%{[observer.version]}-sourcemap" 609 | # when.contains: 610 | # processor.event: "sourcemap" 611 | # 612 | # - index: "apm-%{[observer.version]}-error-%{+yyyy.MM.dd}" 613 | # when.contains: 614 | # processor.event: "error" 615 | # 616 | # - index: "apm-%{[observer.version]}-transaction-%{+yyyy.MM.dd}" 617 | # when.contains: 618 | # processor.event: "transaction" 619 | # 620 | # - index: "apm-%{[observer.version]}-span-%{+yyyy.MM.dd}" 621 | # when.contains: 622 | # processor.event: "span" 623 | # 624 | # - index: "apm-%{[observer.version]}-metric-%{+yyyy.MM.dd}" 625 | # when.contains: 626 | # processor.event: "metric" 627 | # 628 | # - index: "apm-%{[observer.version]}-onboarding-%{+yyyy.MM.dd}" 629 | # when.contains: 630 | # processor.event: "onboarding" 631 | 632 | # A pipeline is a definition of processors applied to documents when ingesting them to Elasticsearch. 633 | # APM Server comes with a default pipeline definition, located at `ingest/pipeline/definition.json`, which is 634 | # loaded to Elasticsearch by default (see `apm-server.register.ingest.pipeline`). 635 | # APM pipeline is enabled by default. To disable it, set `pipeline: _none`. 636 | #pipeline: "apm" 637 | 638 | # Optional HTTP Path. 639 | #path: "/elasticsearch" 640 | 641 | # Custom HTTP headers to add to each request. 642 | #headers: 643 | # X-My-Header: Contents of the header 644 | 645 | # Proxy server url. 646 | #proxy_url: http://proxy:3128 647 | 648 | # The number of times a particular Elasticsearch index operation is attempted. If 649 | # the indexing operation doesn't succeed after this many retries, the events are 650 | # dropped. The default is 3. 651 | #max_retries: 3 652 | 653 | # The maximum number of events to bulk in a single Elasticsearch bulk API index request. 654 | # The default is 50. 655 | #bulk_max_size: 50 656 | 657 | # The number of seconds to wait before trying to reconnect to Elasticsearch 658 | # after a network error. After waiting backoff.init seconds, apm-server 659 | # tries to reconnect. If the attempt fails, the backoff timer is increased 660 | # exponentially up to backoff.max. After a successful connection, the backoff 661 | # timer is reset. The default is 1s. 662 | #backoff.init: 1s 663 | 664 | # The maximum number of seconds to wait before attempting to connect to 665 | # Elasticsearch after a network error. The default is 60s. 666 | #backoff.max: 60s 667 | 668 | # Configure http request timeout before failing an request to Elasticsearch. 669 | #timeout: 90 670 | 671 | # Enable custom SSL settings. Set to false to ignore custom SSL settings for secure communication. 672 | #ssl.enabled: true 673 | 674 | # Optional SSL configuration options. SSL is off by default, change the `protocol` option if you want to enable `https`. 675 | # 676 | # Control the verification of Elasticsearch certificates. Valid values are: 677 | # * full, which verifies that the provided certificate is signed by a trusted 678 | # authority (CA) and also verifies that the server's hostname (or IP address) 679 | # matches the names identified within the certificate. 680 | # * strict, which verifies that the provided certificate is signed by a trusted 681 | # authority (CA) and also verifies that the server's hostname (or IP address) 682 | # matches the names identified within the certificate. If the Subject Alternative 683 | # Name is empty, it returns an error. 684 | # * certificate, which verifies that the provided certificate is signed by a 685 | # trusted authority (CA), but does not perform any hostname verification. 686 | # * none, which performs no verification of the server's certificate. This 687 | # mode disables many of the security benefits of SSL/TLS and should only be used 688 | # after very careful consideration. It is primarily intended as a temporary 689 | # diagnostic mechanism when attempting to resolve TLS errors; its use in 690 | # production environments is strongly discouraged. 691 | #ssl.verification_mode: full 692 | 693 | # List of supported/valid TLS versions. By default all TLS versions 1.0 up to 694 | # 1.2 are enabled. 695 | #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] 696 | 697 | # List of root certificates for HTTPS server verifications. 698 | #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] 699 | 700 | # Certificate for SSL client authentication. 701 | #ssl.certificate: "/etc/pki/client/cert.pem" 702 | 703 | # Client Certificate Key 704 | #ssl.key: "/etc/pki/client/cert.key" 705 | 706 | # Optional passphrase for decrypting the Certificate Key. 707 | # It is recommended to use the provided keystore instead of entering the passphrase in plain text. 708 | #ssl.key_passphrase: '' 709 | 710 | # Configure cipher suites to be used for SSL connections. 711 | #ssl.cipher_suites: [] 712 | 713 | # Configure curve types for ECDHE based cipher suites. 714 | #ssl.curve_types: [] 715 | 716 | # Configure what types of renegotiation are supported. Valid options are 717 | # never, once, and freely. Default is never. 718 | #ssl.renegotiation: never 719 | 720 | # Enable Kerberos support. Kerberos is automatically enabled if any Kerberos setting is set. 721 | #kerberos.enabled: true 722 | 723 | # Authentication type to use with Kerberos. Available options: keytab, password. 724 | #kerberos.auth_type: password 725 | 726 | # Path to the keytab file. It is used when auth_type is set to keytab. 727 | #kerberos.keytab: /etc/elastic.keytab 728 | 729 | # Path to the Kerberos configuration. 730 | #kerberos.config_path: /etc/krb5.conf 731 | 732 | # Name of the Kerberos user. 733 | #kerberos.username: elastic 734 | 735 | # Password of the Kerberos user. It is used when auth_type is set to password. 736 | #kerberos.password: changeme 737 | 738 | # Kerberos realm. 739 | #kerberos.realm: ELASTIC 740 | 741 | 742 | #----------------------------- Console output ----------------------------- 743 | #output.console: 744 | # Boolean flag to enable or disable the output module. 745 | #enabled: false 746 | 747 | # Configure JSON encoding. 748 | #codec.json: 749 | # Pretty-print JSON event. 750 | #pretty: false 751 | 752 | # Configure escaping HTML symbols in strings. 753 | #escape_html: false 754 | 755 | #---------------------------- Logstash output ----------------------------- 756 | #output.logstash: 757 | # Boolean flag to enable or disable the output module. 758 | #enabled: false 759 | 760 | # The Logstash hosts. 761 | #hosts: ["localhost:5044"] 762 | 763 | # Number of workers per Logstash host. 764 | #worker: 1 765 | 766 | # Set gzip compression level. 767 | #compression_level: 3 768 | 769 | # Configure escaping html symbols in strings. 770 | #escape_html: true 771 | 772 | # Optional maximum time to live for a connection to Logstash, after which the 773 | # connection will be re-established. A value of `0s` (the default) will 774 | # disable this feature. 775 | # 776 | # Not yet supported for async connections (i.e. with the "pipelining" option set). 777 | #ttl: 30s 778 | 779 | # Optional load balance the events between the Logstash hosts. Default is false. 780 | #loadbalance: false 781 | 782 | # Number of batches to be sent asynchronously to Logstash while processing 783 | # new batches. 784 | #pipelining: 2 785 | 786 | # If enabled only a subset of events in a batch of events is transferred per 787 | # group. The number of events to be sent increases up to `bulk_max_size` 788 | # if no error is encountered. 789 | #slow_start: false 790 | 791 | # The number of seconds to wait before trying to reconnect to Logstash 792 | # after a network error. After waiting backoff.init seconds, apm-server 793 | # tries to reconnect. If the attempt fails, the backoff timer is increased 794 | # exponentially up to backoff.max. After a successful connection, the backoff 795 | # timer is reset. The default is 1s. 796 | #backoff.init: 1s 797 | 798 | # The maximum number of seconds to wait before attempting to connect to 799 | # Logstash after a network error. The default is 60s. 800 | #backoff.max: 60s 801 | 802 | # Optional index name. The default index name is set to apm 803 | # in all lowercase. 804 | #index: 'apm' 805 | 806 | # SOCKS5 proxy server URL 807 | #proxy_url: socks5://user:password@socks5-server:2233 808 | 809 | # Resolve names locally when using a proxy server. Defaults to false. 810 | #proxy_use_local_resolver: false 811 | 812 | # Enable SSL support. SSL is automatically enabled if any SSL setting is set. 813 | #ssl.enabled: false 814 | 815 | # Optional SSL configuration options. SSL is off by default. 816 | # 817 | # Control the verification of Logstash certificates. Valid values are: 818 | # * full, which verifies that the provided certificate is signed by a trusted 819 | # authority (CA) and also verifies that the server's hostname (or IP address) 820 | # matches the names identified within the certificate. 821 | # * strict, which verifies that the provided certificate is signed by a trusted 822 | # authority (CA) and also verifies that the server's hostname (or IP address) 823 | # matches the names identified within the certificate. If the Subject Alternative 824 | # Name is empty, it returns an error. 825 | # * certificate, which verifies that the provided certificate is signed by a 826 | # trusted authority (CA), but does not perform any hostname verification. 827 | # * none, which performs no verification of the server's certificate. This 828 | # mode disables many of the security benefits of SSL/TLS and should only be used 829 | # after very careful consideration. It is primarily intended as a temporary 830 | # diagnostic mechanism when attempting to resolve TLS errors; its use in 831 | # production environments is strongly discouraged. 832 | #ssl.verification_mode: full 833 | 834 | # List of supported/valid TLS versions. By default all TLS versions 1.0 up to 835 | # 1.2 are enabled. 836 | #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] 837 | 838 | # List of root certificates for HTTPS server verifications. 839 | #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] 840 | 841 | # Certificate for SSL client authentication. 842 | #ssl.certificate: "/etc/pki/client/cert.pem" 843 | 844 | # Client Certificate Key 845 | #ssl.key: "/etc/pki/client/cert.key" 846 | 847 | # Optional passphrase for decrypting the Certificate Key. 848 | # It is recommended to use the provided keystore instead of entering the passphrase in plain text. 849 | #ssl.key_passphrase: '' 850 | 851 | # Configure cipher suites to be used for SSL connections. 852 | #ssl.cipher_suites: [] 853 | 854 | # Configure curve types for ECDHE based cipher suites. 855 | #ssl.curve_types: [] 856 | 857 | # Configure what types of renegotiation are supported. Valid options are 858 | # never, once, and freely. Default is never. 859 | #ssl.renegotiation: never 860 | 861 | #------------------------------ Kafka output ------------------------------ 862 | #output.kafka: 863 | # Boolean flag to enable or disable the output module. 864 | #enabled: false 865 | 866 | # The list of Kafka broker addresses from where to fetch the cluster metadata. 867 | # The cluster metadata contain the actual Kafka brokers events are published 868 | # to. 869 | #hosts: ["localhost:9092"] 870 | 871 | # The Kafka topic used for produced events. The setting can be a format string 872 | # using any event field. To set the topic from document type use `%{[type]}`. 873 | #topic: beats 874 | 875 | # The Kafka event key setting. Use format string to create unique event key. 876 | # By default no event key will be generated. 877 | #key: '' 878 | 879 | # The Kafka event partitioning strategy. Default hashing strategy is `hash` 880 | # using the `output.kafka.key` setting or randomly distributes events if 881 | # `output.kafka.key` is not configured. 882 | #partition.hash: 883 | # If enabled, events will only be published to partitions with reachable 884 | # leaders. Default is false. 885 | #reachable_only: false 886 | 887 | # Configure alternative event field names used to compute the hash value. 888 | # If empty `output.kafka.key` setting will be used. 889 | # Default value is empty list. 890 | #hash: [] 891 | 892 | # Authentication details. Password is required if username is set. 893 | #username: '' 894 | #password: '' 895 | 896 | # Kafka version libbeat is assumed to run against. Defaults to the "1.0.0". 897 | #version: '1.0.0' 898 | 899 | # Configure JSON encoding. 900 | #codec.json: 901 | # Pretty print json event 902 | #pretty: false 903 | 904 | # Configure escaping html symbols in strings. 905 | #escape_html: true 906 | 907 | # Metadata update configuration. Metadata do contain leader information 908 | # deciding which broker to use when publishing. 909 | #metadata: 910 | # Max metadata request retry attempts when cluster is in middle of leader 911 | # election. Defaults to 3 retries. 912 | #retry.max: 3 913 | 914 | # Waiting time between retries during leader elections. Default is 250ms. 915 | #retry.backoff: 250ms 916 | 917 | # Refresh metadata interval. Defaults to every 10 minutes. 918 | #refresh_frequency: 10m 919 | 920 | # The number of concurrent load-balanced Kafka output workers. 921 | #worker: 1 922 | 923 | # The number of times to retry publishing an event after a publishing failure. 924 | # After the specified number of retries, the events are typically dropped. 925 | # Set max_retries to a value less than 0 to retry 926 | # until all events are published. The default is 3. 927 | #max_retries: 3 928 | 929 | # The maximum number of events to bulk in a single Kafka request. The default 930 | # is 2048. 931 | #bulk_max_size: 2048 932 | 933 | # The number of seconds to wait for responses from the Kafka brokers before 934 | # timing out. The default is 30s. 935 | #timeout: 30s 936 | 937 | # The maximum duration a broker will wait for number of required ACKs. The 938 | # default is 10s. 939 | #broker_timeout: 10s 940 | 941 | # The number of messages buffered for each Kafka broker. The default is 256. 942 | #channel_buffer_size: 256 943 | 944 | # The keep-alive period for an active network connection. If 0s, keep-alives 945 | # are disabled. The default is 0 seconds. 946 | #keep_alive: 0 947 | 948 | # Sets the output compression codec. Must be one of none, snappy and gzip. The 949 | # default is gzip. 950 | #compression: gzip 951 | 952 | # Set the compression level. Currently only gzip provides a compression level 953 | # between 0 and 9. The default value is chosen by the compression algorithm. 954 | #compression_level: 4 955 | 956 | # The maximum permitted size of JSON-encoded messages. Bigger messages will be 957 | # dropped. The default value is 1000000 (bytes). This value should be equal to 958 | # or less than the broker's message.max.bytes. 959 | #max_message_bytes: 1000000 960 | 961 | # The ACK reliability level required from broker. 0=no response, 1=wait for 962 | # local commit, -1=wait for all replicas to commit. The default is 1. Note: 963 | # If set to 0, no ACKs are returned by Kafka. Messages might be lost silently 964 | # on error. 965 | #required_acks: 1 966 | 967 | # The configurable ClientID used for logging, debugging, and auditing 968 | # purposes. The default is "beats". 969 | #client_id: beats 970 | 971 | # Enable SSL support. SSL is automatically enabled if any SSL setting is set. 972 | #ssl.enabled: false 973 | 974 | # Optional SSL configuration options. SSL is off by default. 975 | # 976 | # Control the verification of Kafka certificates. Valid values are: 977 | # * full, which verifies that the provided certificate is signed by a trusted 978 | # authority (CA) and also verifies that the server's hostname (or IP address) 979 | # matches the names identified within the certificate. 980 | # * strict, which verifies that the provided certificate is signed by a trusted 981 | # authority (CA) and also verifies that the server's hostname (or IP address) 982 | # matches the names identified within the certificate. If the Subject Alternative 983 | # Name is empty, it returns an error. 984 | # * certificate, which verifies that the provided certificate is signed by a 985 | # trusted authority (CA), but does not perform any hostname verification. 986 | # * none, which performs no verification of the server's certificate. This 987 | # mode disables many of the security benefits of SSL/TLS and should only be used 988 | # after very careful consideration. It is primarily intended as a temporary 989 | # diagnostic mechanism when attempting to resolve TLS errors; its use in 990 | # production environments is strongly discouraged. 991 | #ssl.verification_mode: full 992 | 993 | # List of supported/valid TLS versions. By default all TLS versions 1.0 up to 994 | # 1.2 are enabled. 995 | #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] 996 | 997 | # List of root certificates for HTTPS server verifications. 998 | #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] 999 | 1000 | # Certificate for SSL client authentication. 1001 | #ssl.certificate: "/etc/pki/client/cert.pem" 1002 | 1003 | # Client Certificate Key 1004 | #ssl.key: "/etc/pki/client/cert.key" 1005 | 1006 | # Optional passphrase for decrypting the Certificate Key. 1007 | # It is recommended to use the provided keystore instead of entering the passphrase in plain text. 1008 | #ssl.key_passphrase: '' 1009 | 1010 | # Configure cipher suites to be used for SSL connections. 1011 | #ssl.cipher_suites: [] 1012 | 1013 | # Configure curve types for ECDHE based cipher suites. 1014 | #ssl.curve_types: [] 1015 | 1016 | # Configure what types of renegotiation are supported. Valid options are 1017 | # never, once, and freely. Default is never. 1018 | #ssl.renegotiation: never 1019 | 1020 | # Authentication type to use with Kerberos. Available options: keytab, password. 1021 | #kerberos.auth_type: password 1022 | 1023 | # Path to the keytab file. It is used when auth_type is set to keytab. 1024 | #kerberos.keytab: /etc/krb5kdc/kafka.keytab 1025 | 1026 | # Path to the Kerberos configuration. 1027 | #kerberos.config_path: /etc/path/config 1028 | 1029 | # The service principal name. 1030 | #kerberos.service_name: HTTP/my-service@realm 1031 | 1032 | # Name of the Kerberos user. It is used when auth_type is set to password. 1033 | #kerberos.username: elastic 1034 | 1035 | # Password of the Kerberos user. It is used when auth_type is set to password. 1036 | #kerberos.password: changeme 1037 | 1038 | # Kerberos realm. 1039 | #kerberos.realm: ELASTIC 1040 | 1041 | #============================= Instrumentation ============================= 1042 | 1043 | # Instrumentation support for the server's HTTP endpoints and event publisher. 1044 | #instrumentation: 1045 | 1046 | # Set to true to enable instrumentation of the APM Server itself. 1047 | #enabled: false 1048 | 1049 | # Environment in which the APM Server is running on (eg: staging, production, etc.) 1050 | #environment: "" 1051 | 1052 | # Hosts to report instrumentation results to. 1053 | # For reporting to itself, leave this field commented 1054 | #hosts: 1055 | # - http://remote-apm-server:8200 1056 | 1057 | # API Key for the remote APM Server(s). 1058 | # If api_key is set then secret_token will be ignored. 1059 | #api_key: 1060 | 1061 | # Secret token for the remote APM Server(s). 1062 | #secret_token: 1063 | 1064 | # Enable profiling of the server, recording profile samples as events. 1065 | # 1066 | # This feature is experimental. 1067 | #profiling: 1068 | #cpu: 1069 | # Set to true to enable CPU profiling. 1070 | #enabled: false 1071 | #interval: 60s 1072 | #duration: 10s 1073 | #heap: 1074 | # Set to true to enable heap profiling. 1075 | #enabled: false 1076 | #interval: 60s 1077 | 1078 | #================================= Paths ================================== 1079 | 1080 | # The home path for the apm-server installation. This is the default base path 1081 | # for all other path settings and for miscellaneous files that come with the 1082 | # distribution. 1083 | # If not set by a CLI flag or in the configuration file, the default for the 1084 | # home path is the location of the binary. 1085 | #path.home: 1086 | 1087 | # The configuration path for the apm-server installation. This is the default 1088 | # base path for configuration files, including the main YAML configuration file 1089 | # and the Elasticsearch template file. If not set by a CLI flag or in the 1090 | # configuration file, the default for the configuration path is the home path. 1091 | #path.config: ${path.home} 1092 | 1093 | # The data path for the apm-server installation. This is the default base path 1094 | # for all the files in which apm-server needs to store its data. If not set by a 1095 | # CLI flag or in the configuration file, the default for the data path is a data 1096 | # subdirectory inside the home path. 1097 | #path.data: ${path.home}/data 1098 | 1099 | # The logs path for an apm-server installation. If not set by a CLI flag or in the 1100 | # configuration file, the default is a logs subdirectory inside the home path. 1101 | #path.logs: ${path.home}/logs 1102 | 1103 | #================================= Logging ================================= 1104 | 1105 | # There are three options for the log output: syslog, file, and stderr. 1106 | # Windows systems default to file output. All other systems default to syslog. 1107 | 1108 | # Sets the minimum log level. The default log level is info. 1109 | # Available log levels are: error, warning, info, or debug. 1110 | #logging.level: info 1111 | 1112 | # Enable debug output for selected components. To enable all selectors use ["*"]. 1113 | # Other available selectors are "beat", "publish", or "service". 1114 | # Multiple selectors can be chained. 1115 | #logging.selectors: [ ] 1116 | 1117 | # Send all logging output to syslog. The default is false. 1118 | #logging.to_syslog: true 1119 | 1120 | # If enabled, apm-server periodically logs its internal metrics that have changed 1121 | # in the last period. For each metric that changed, the delta from the value at 1122 | # the beginning of the period is logged. Also, the total values for 1123 | # all non-zero internal metrics are logged on shutdown. The default is false. 1124 | #logging.metrics.enabled: false 1125 | 1126 | # The period after which to log the internal metrics. The default is 30s. 1127 | #logging.metrics.period: 30s 1128 | 1129 | # Logging to rotating files. When true, writes all logging output to files. 1130 | # The log files are automatically rotated when the log file size limit is reached. 1131 | #logging.to_files: true 1132 | #logging.files: 1133 | # Configure the path where the logs are written. The default is the logs directory 1134 | # under the home path (the binary location). 1135 | #path: /var/log/apm-server 1136 | 1137 | # The name of the files where the logs are written to. 1138 | #name: apm-server 1139 | 1140 | # Configure log file size limit. If limit is reached, log file will be 1141 | # automatically rotated. 1142 | #rotateeverybytes: 10485760 # = 10MB 1143 | 1144 | # Number of rotated log files to keep. Oldest files will be deleted first. 1145 | #keepfiles: 7 1146 | 1147 | # The permissions mask to apply when rotating log files. The default value is 0600. 1148 | # Must be a valid Unix-style file permissions mask expressed in octal notation. 1149 | #permissions: 0600 1150 | 1151 | # Enable log file rotation on time intervals in addition to size-based rotation. 1152 | # Intervals must be at least 1s. Values of 1m, 1h, 24h, 7*24h, 30*24h, and 365*24h 1153 | # are boundary-aligned with minutes, hours, days, weeks, months, and years as 1154 | # reported by the local system clock. All other intervals are calculated from the 1155 | # Unix epoch. Defaults to disabled. 1156 | #interval: 0 1157 | 1158 | # Set to true to log messages in json format. 1159 | #logging.json: true 1160 | 1161 | # Set to true, to log messages with minimal required Elastic Common Schema (ECS) 1162 | # information. Recommended to use in combination with `logging.json=true`. 1163 | #logging.ecs: true 1164 | 1165 | #=============================== HTTP Endpoint =============================== 1166 | 1167 | # apm-server can expose internal metrics through a HTTP endpoint. For security 1168 | # reasons the endpoint is disabled by default. This feature is currently experimental. 1169 | # Stats can be access through http://localhost:5066/stats. For pretty JSON output 1170 | # append ?pretty to the URL. 1171 | 1172 | # Defines if the HTTP endpoint is enabled. 1173 | #http.enabled: false 1174 | 1175 | # The HTTP endpoint will bind to this hostname or IP address. It is recommended to use only localhost. 1176 | #http.host: localhost 1177 | 1178 | # Port on which the HTTP endpoint will bind. Default is 5066. 1179 | #http.port: 5066 1180 | 1181 | #============================= X-pack Monitoring ============================= 1182 | 1183 | # APM server can export internal metrics to a central Elasticsearch monitoring 1184 | # cluster. This requires x-pack monitoring to be enabled in Elasticsearch. The 1185 | # reporting is disabled by default. 1186 | 1187 | # Set to true to enable the monitoring reporter. 1188 | #monitoring.enabled: false 1189 | 1190 | # Most settings from the Elasticsearch output are accepted here as well. 1191 | # Note that these settings should be configured to point to your Elasticsearch *monitoring* cluster. 1192 | # Any setting that is not set is automatically inherited from the Elasticsearch 1193 | # output configuration. This means that if you have the Elasticsearch output configured, 1194 | # you can simply uncomment the following line. 1195 | #monitoring.elasticsearch: 1196 | 1197 | # Protocol - either `http` (default) or `https`. 1198 | #protocol: "https" 1199 | 1200 | # Authentication credentials - either API key or username/password. 1201 | #api_key: "id:api_key" 1202 | #username: "elastic" 1203 | #password: "changeme" 1204 | 1205 | # Array of hosts to connect to. 1206 | # Scheme and port can be left out and will be set to the default (`http` and `9200`). 1207 | # In case you specify and additional path, the scheme is required: `http://localhost:9200/path`. 1208 | # IPv6 addresses should always be defined as: `https://[2001:db8::1]:9200`. 1209 | #hosts: ["localhost:9200"] 1210 | 1211 | # Set gzip compression level. 1212 | #compression_level: 0 1213 | 1214 | # Dictionary of HTTP parameters to pass within the URL with index operations. 1215 | #parameters: 1216 | #param1: value1 1217 | #param2: value2 1218 | 1219 | # Custom HTTP headers to add to each request. 1220 | #headers: 1221 | # X-My-Header: Contents of the header 1222 | 1223 | # Proxy server url. 1224 | #proxy_url: http://proxy:3128 1225 | 1226 | # The number of times a particular Elasticsearch index operation is attempted. If 1227 | # the indexing operation doesn't succeed after this many retries, the events are 1228 | # dropped. The default is 3. 1229 | #max_retries: 3 1230 | 1231 | # The maximum number of events to bulk in a single Elasticsearch bulk API index request. 1232 | # The default is 50. 1233 | #bulk_max_size: 50 1234 | 1235 | # The number of seconds to wait before trying to reconnect to Elasticsearch 1236 | # after a network error. After waiting backoff.init seconds, apm-server 1237 | # tries to reconnect. If the attempt fails, the backoff timer is increased 1238 | # exponentially up to backoff.max. After a successful connection, the backoff 1239 | # timer is reset. The default is 1s. 1240 | #backoff.init: 1s 1241 | 1242 | # The maximum number of seconds to wait before attempting to connect to 1243 | # Elasticsearch after a network error. The default is 60s. 1244 | #backoff.max: 60s 1245 | 1246 | # Configure HTTP request timeout before failing an request to Elasticsearch. 1247 | #timeout: 90 1248 | 1249 | # Enable custom SSL settings. Set to false to ignore custom SSL settings for secure communication. 1250 | #ssl.enabled: true 1251 | 1252 | # Optional SSL configuration options. SSL is off by default, change the `protocol` option if you want to enable `https`. 1253 | # 1254 | # Control the verification of Elasticsearch certificates. Valid values are: 1255 | # * full, which verifies that the provided certificate is signed by a trusted 1256 | # authority (CA) and also verifies that the server's hostname (or IP address) 1257 | # matches the names identified within the certificate. 1258 | # * strict, which verifies that the provided certificate is signed by a trusted 1259 | # authority (CA) and also verifies that the server's hostname (or IP address) 1260 | # matches the names identified within the certificate. If the Subject Alternative 1261 | # Name is empty, it returns an error. 1262 | # * certificate, which verifies that the provided certificate is signed by a 1263 | # trusted authority (CA), but does not perform any hostname verification. 1264 | # * none, which performs no verification of the server's certificate. This 1265 | # mode disables many of the security benefits of SSL/TLS and should only be used 1266 | # after very careful consideration. It is primarily intended as a temporary 1267 | # diagnostic mechanism when attempting to resolve TLS errors; its use in 1268 | # production environments is strongly discouraged. 1269 | #ssl.verification_mode: full 1270 | 1271 | # List of supported/valid TLS versions. By default all TLS versions 1.0 up to 1272 | # 1.2 are enabled. 1273 | #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] 1274 | 1275 | # List of root certificates for HTTPS server verifications. 1276 | #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] 1277 | 1278 | # Certificate for SSL client authentication. 1279 | #ssl.certificate: "/etc/pki/client/cert.pem" 1280 | 1281 | # Client Certificate Key 1282 | #ssl.key: "/etc/pki/client/cert.key" 1283 | 1284 | # Optional passphrase for decrypting the Certificate Key. 1285 | # It is recommended to use the provided keystore instead of entering the passphrase in plain text. 1286 | #ssl.key_passphrase: '' 1287 | 1288 | # Configure cipher suites to be used for SSL connections. 1289 | #ssl.cipher_suites: [] 1290 | 1291 | # Configure curve types for ECDHE based cipher suites. 1292 | #ssl.curve_types: [] 1293 | 1294 | # Configure what types of renegotiation are supported. Valid options are 1295 | # never, once, and freely. Default is never. 1296 | #ssl.renegotiation: never 1297 | 1298 | # Enable Kerberos support. Kerberos is automatically enabled if any Kerberos setting is set. 1299 | #kerberos.enabled: true 1300 | 1301 | # Authentication type to use with Kerberos. Available options: keytab, password. 1302 | #kerberos.auth_type: password 1303 | 1304 | # Path to the keytab file. It is used when auth_type is set to keytab. 1305 | #kerberos.keytab: /etc/elastic.keytab 1306 | 1307 | # Path to the Kerberos configuration. 1308 | #kerberos.config_path: /etc/krb5.conf 1309 | 1310 | # Name of the Kerberos user. 1311 | #kerberos.username: elastic 1312 | 1313 | # Password of the Kerberos user. It is used when auth_type is set to password. 1314 | #kerberos.password: changeme 1315 | 1316 | # Kerberos realm. 1317 | #kerberos.realm: ELASTIC 1318 | 1319 | #metrics.period: 10s 1320 | #state.period: 1m -------------------------------------------------------------------------------- /app/.docker/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | python3 manage.py migrate 4 | gunicorn codeprogress.wsgi:application --bind 0.0.0.0:8000 -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | db.sqlite3 2 | .idea/* 3 | .docker/pgdata 4 | *.pyc 5 | __pycache__ -------------------------------------------------------------------------------- /app/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.11 2 | ENV PYTHONUNBUFFERED 1 3 | RUN mkdir /code 4 | WORKDIR /code 5 | COPY requirements.txt /code/ 6 | RUN pip install -r requirements.txt -------------------------------------------------------------------------------- /app/codeprogress/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeedu/fc2-observabilidade-elastic/ac2c8868915b28a4e034900be174adb4ce35ce9a/app/codeprogress/__init__.py -------------------------------------------------------------------------------- /app/codeprogress/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for codeprogress project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'codeprogress.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /app/codeprogress/logger.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | 3 | import json_log_formatter 4 | 5 | import logging 6 | from django.utils.timezone import now 7 | 8 | from codeprogress import settings 9 | 10 | 11 | class CustomisedJSONFormatter(json_log_formatter.JSONFormatter): 12 | def json_record(self, message: str, extra: dict, record: logging.LogRecord): 13 | context = extra 14 | django = { 15 | 'app': settings.APP_ID, 16 | 'name': record.name, 17 | 'filename': record.filename, 18 | 'funcName': record.funcName, 19 | 'msecs': record.msecs, 20 | } 21 | if record.exc_info: 22 | django['exc_info'] = self.formatException(record.exc_info) 23 | 24 | return { 25 | 'message': message, 26 | 'timestamp': now(), 27 | 'level': record.levelname, 28 | 'context': context, 29 | 'django': django 30 | } -------------------------------------------------------------------------------- /app/codeprogress/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for codeprogress project. 3 | 4 | Generated by 'django-admin startproject' using Django 3.0.8. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/3.0/ref/settings/ 11 | """ 12 | 13 | import os 14 | 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 16 | from pathlib import Path 17 | 18 | from codeprogress.logger import CustomisedJSONFormatter 19 | 20 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 21 | 22 | 23 | # Quick-start development settings - unsuitable for production 24 | # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ 25 | 26 | # SECURITY WARNING: keep the secret key used in production secret! 27 | SECRET_KEY = 'odba@^9%(+^=ixf(pr&ym^(4#7aw@-&ip-_t#p8oghr0-z&(hp' 28 | 29 | # SECURITY WARNING: don't run with debug turned on in production! 30 | DEBUG = True 31 | 32 | ALLOWED_HOSTS = ['*'] 33 | 34 | 35 | # Application definition 36 | 37 | INSTALLED_APPS = [ 38 | 'exemplo.apps.ExemploConfig', 39 | 'django.contrib.admin', 40 | 'django.contrib.auth', 41 | 'django.contrib.contenttypes', 42 | 'django.contrib.sessions', 43 | 'django.contrib.messages', 44 | 'django.contrib.staticfiles', 45 | 'elasticapm.contrib.django', 46 | ] 47 | 48 | MIDDLEWARE = [ 49 | 'elasticapm.contrib.django.middleware.TracingMiddleware', 50 | 'django.middleware.security.SecurityMiddleware', 51 | 'django.contrib.sessions.middleware.SessionMiddleware', 52 | 'django.middleware.common.CommonMiddleware', 53 | 'django.middleware.csrf.CsrfViewMiddleware', 54 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 55 | 'django.contrib.messages.middleware.MessageMiddleware', 56 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 57 | ] 58 | 59 | ELASTIC_APM = { 60 | # Set required service name. Allowed characters: 61 | # a-z, A-Z, 0-9, -, _, and space 62 | 'SERVICE_NAME': 'codeprogress', 63 | 64 | # Set custom APM Server URL (default: http://localhost:8200) 65 | 'SERVER_URL': 'http://apm:8200', 66 | 'DEBUG': True, 67 | 'ENVIRONMENT': 'production', 68 | } 69 | 70 | ROOT_URLCONF = 'codeprogress.urls' 71 | 72 | TEMPLATES = [ 73 | { 74 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 75 | 'DIRS': [], 76 | 'APP_DIRS': True, 77 | 'OPTIONS': { 78 | 'context_processors': [ 79 | 'django.template.context_processors.debug', 80 | 'django.template.context_processors.request', 81 | 'django.contrib.auth.context_processors.auth', 82 | 'django.contrib.messages.context_processors.messages', 83 | 'elasticapm.contrib.django.context_processors.rum_tracing', 84 | ], 85 | }, 86 | }, 87 | ] 88 | 89 | WSGI_APPLICATION = 'codeprogress.wsgi.application' 90 | 91 | 92 | # Database 93 | # https://docs.djangoproject.com/en/3.0/ref/settings/#databases 94 | 95 | DATABASES = { 96 | 'default': { 97 | 'ENGINE': 'django.db.backends.sqlite3', 98 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 99 | } 100 | } 101 | 102 | 103 | # Password validation 104 | # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators 105 | 106 | AUTH_PASSWORD_VALIDATORS = [ 107 | { 108 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 109 | }, 110 | { 111 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 112 | }, 113 | { 114 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 115 | }, 116 | { 117 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 118 | }, 119 | ] 120 | 121 | 122 | # Internationalization 123 | # https://docs.djangoproject.com/en/3.0/topics/i18n/ 124 | 125 | LANGUAGE_CODE = 'en-us' 126 | 127 | TIME_ZONE = 'UTC' 128 | 129 | USE_I18N = True 130 | 131 | USE_L10N = True 132 | 133 | USE_TZ = True 134 | 135 | 136 | # Static files (CSS, JavaScript, Images) 137 | # https://docs.djangoproject.com/en/3.0/howto/static-files/ 138 | 139 | STATIC_URL = '/static/' 140 | APP_ID = 'codeprogress' 141 | LOGGING = { 142 | 'version': 1, 143 | 'disable_existing_loggers': True, 144 | 'formatters': { 145 | 'verbose': { 146 | 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' 147 | }, 148 | }, 149 | 'handlers': { 150 | 'elasticapm': { 151 | 'level': 'WARNING', 152 | 'class': 'elasticapm.contrib.django.handlers.LoggingHandler', 153 | # 'filename': Path(BASE_DIR).resolve().joinpath('logs', 'app.log'), 154 | # 'maxBytes': 1024 * 1024 * 15, # 15MB 155 | # 'backupCount': 10, 156 | }, 157 | 'console': { 158 | 'level': 'DEBUG', 159 | 'class': 'logging.StreamHandler', 160 | 'formatter': 'verbose' 161 | } 162 | }, 163 | 'loggers': { 164 | 'django.db.backends': { 165 | 'level': 'ERROR', 166 | 'handlers': ['elasticapm'], 167 | 'propagate': True, 168 | }, 169 | 'mysite': { 170 | 'level': 'WARNING', 171 | 'handlers': ['elasticapm'], 172 | 'propagate': True, 173 | }, 174 | # Log errors from the Elastic APM module to the console (recommended) 175 | 'elasticapm.errors': { 176 | 'level': 'ERROR', 177 | 'handlers': ['elasticapm'], 178 | 'propagate': True, 179 | }, 180 | }, 181 | } -------------------------------------------------------------------------------- /app/codeprogress/urls.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from django.urls import path, include 3 | urlpatterns = [ 4 | path('admin/', admin.site.urls), 5 | path('exemplo/', include('exemplo.urls')), 6 | 7 | ] -------------------------------------------------------------------------------- /app/codeprogress/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for codeprogress project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'codeprogress.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /app/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeedu/fc2-observabilidade-elastic/ac2c8868915b28a4e034900be174adb4ce35ce9a/app/db.sqlite3 -------------------------------------------------------------------------------- /app/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | db: 5 | image: postgres 6 | container_name: postgres 7 | tty: true 8 | environment: 9 | - POSTGRES_DB=commerce_admin 10 | - POSTGRES_USER=postgres 11 | - POSTGRES_PASSWORD=root 12 | volumes: 13 | - .docker/pgdata:/var/lib/postgresql/data 14 | ports: 15 | - "5432:5432" 16 | networks: 17 | - observability 18 | 19 | pgadmin: 20 | image: dpage/pgadmin4 21 | container_name: pgadmin 22 | tty: true 23 | environment: 24 | - PGADMIN_DEFAULT_EMAIL=admin@fullcycle.com.br 25 | - PGADMIN_DEFAULT_PASSWORD=123456 26 | ports: 27 | - "9001:80" 28 | networks: 29 | - observability 30 | 31 | app: 32 | build: . 33 | container_name: app_python 34 | command: python manage.py runserver 0.0.0.0:8000 35 | volumes: 36 | - .:/code 37 | ports: 38 | - "8000:8000" 39 | depends_on: 40 | - db 41 | networks: 42 | - observability 43 | 44 | nginx: 45 | build: ../nginx 46 | container_name: nginx 47 | ports: 48 | - "8280:80" 49 | networks: 50 | - observability 51 | 52 | networks: 53 | observability: 54 | external: true -------------------------------------------------------------------------------- /app/exemplo/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeedu/fc2-observabilidade-elastic/ac2c8868915b28a4e034900be174adb4ce35ce9a/app/exemplo/__init__.py -------------------------------------------------------------------------------- /app/exemplo/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | from .models import Question 5 | 6 | admin.site.register(Question) -------------------------------------------------------------------------------- /app/exemplo/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class ExemploConfig(AppConfig): 5 | name = 'exemplo' 6 | -------------------------------------------------------------------------------- /app/exemplo/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.0.8 on 2020-07-09 22:27 2 | 3 | from django.db import migrations, models 4 | import django.db.models.deletion 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | initial = True 10 | 11 | dependencies = [ 12 | ] 13 | 14 | operations = [ 15 | migrations.CreateModel( 16 | name='Question', 17 | fields=[ 18 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 19 | ('question_text', models.CharField(max_length=200)), 20 | ('pub_date', models.DateTimeField(verbose_name='date published')), 21 | ], 22 | ), 23 | migrations.CreateModel( 24 | name='Choice', 25 | fields=[ 26 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 27 | ('choice_text', models.CharField(max_length=200)), 28 | ('votes', models.IntegerField(default=0)), 29 | ('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='exemplo.Question')), 30 | ], 31 | ), 32 | ] 33 | -------------------------------------------------------------------------------- /app/exemplo/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeedu/fc2-observabilidade-elastic/ac2c8868915b28a4e034900be174adb4ce35ce9a/app/exemplo/migrations/__init__.py -------------------------------------------------------------------------------- /app/exemplo/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.utils import timezone 3 | 4 | class Question(models.Model): 5 | question_text = models.CharField(max_length=200) 6 | pub_date = models.DateTimeField('date published') 7 | 8 | def __str__(self): 9 | return self.question_text 10 | 11 | def was_published_recently(self): 12 | return self.pub_date >= timezone.now() - datetime.timedelta(days=1) 13 | 14 | 15 | class Choice(models.Model): 16 | question = models.ForeignKey(Question, on_delete=models.CASCADE) 17 | choice_text = models.CharField(max_length=200) 18 | votes = models.IntegerField(default=0) 19 | 20 | def __str__(self): 21 | return self.choice_text 22 | 23 | -------------------------------------------------------------------------------- /app/exemplo/templates/exemplo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Full Cycle 8 | 9 | 18 | 19 | 20 |

Exemplo Full Cycle de Questões

21 | {% if latest_question_list %} 22 |
    23 | {% for question in latest_question_list %} 24 |
  • {{ question.question_text }}
  • 25 | {% endfor %} 26 |
27 | {% else %} 28 |

No polls are available.

29 | {% endif %} 30 | 31 | -------------------------------------------------------------------------------- /app/exemplo/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /app/exemplo/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | 3 | from . import views 4 | 5 | urlpatterns = [ 6 | path('', views.index, name='index'), 7 | ] -------------------------------------------------------------------------------- /app/exemplo/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | from .models import Question 4 | import logging 5 | logger = logging.getLogger('mysite') 6 | 7 | # Create your views here. 8 | def index(request): 9 | latest_question_list = Question.objects.order_by('-pub_date')[:5] 10 | context = {'latest_question_list': latest_question_list} 11 | logger.warning( 12 | 'This is a warning!', 13 | exc_info=True 14 | ) 15 | return render(request, 'exemplo/index.html', context) -------------------------------------------------------------------------------- /app/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'codeprogress.settings') 9 | try: 10 | from django.core.management import execute_from_command_line 11 | except ImportError as exc: 12 | raise ImportError( 13 | "Couldn't import Django. Are you sure it's installed and " 14 | "available on your PYTHONPATH environment variable? Did you " 15 | "forget to activate a virtual environment?" 16 | ) from exc 17 | execute_from_command_line(sys.argv) 18 | 19 | 20 | if __name__ == '__main__': 21 | main() 22 | -------------------------------------------------------------------------------- /app/requirements.txt: -------------------------------------------------------------------------------- 1 | Django==3.0.8 2 | gunicorn==20.0.4 3 | psycopg2-binary>=2.8 4 | JSON-log-formatter==0.3.1 5 | elastic-apm -------------------------------------------------------------------------------- /beats/heartbeat/heartbeat.yml: -------------------------------------------------------------------------------- 1 | heartbeat.monitors: 2 | - type: http 3 | schedule: '@every 5s' 4 | urls: 5 | - http://elasticsearch:9200 6 | - http://kibana:5601 7 | - http://app:8000 8 | 9 | - type: icmp 10 | schedule: '@every 5s' 11 | hosts: 12 | - elasticsearch 13 | - kibana 14 | - apm 15 | - metricbeat 16 | 17 | processors: 18 | - add_cloud_metadata: ~ 19 | 20 | output.elasticsearch: 21 | hosts: 'elasticsearch:9200' 22 | username: 'elastic' 23 | password: 'changeme' -------------------------------------------------------------------------------- /beats/metric/metricbeat.yml: -------------------------------------------------------------------------------- 1 | metricbeat.modules: 2 | - module: docker 3 | metricsets: ["container", "cpu", "diskio", "event", "healthcheck", "image", "info", "memory", "network"] 4 | hosts: ["unix:///var/run/docker.sock"] 5 | period: 10s 6 | 7 | - module: elasticsearch 8 | metricsets: ["node", "node_stats", "cluster_stats", "index"] 9 | period: 10s 10 | hosts: ["elasticsearch:9200"] 11 | 12 | 13 | output.elasticsearch: 14 | hosts: ["elasticsearch:9200"] 15 | 16 | setup.kibana: 17 | host: "kibana:5601" 18 | 19 | setup.dashboards.enabled: true -------------------------------------------------------------------------------- /docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | 5 | elasticsearch: 6 | image: docker.elastic.co/elasticsearch/elasticsearch:7.13.0 7 | container_name: elasticsearch 8 | environment: 9 | - node.name=elasticsearch 10 | - cluster.name=es-docker-cluster 11 | - bootstrap.memory_lock=true 12 | - "ES_JAVA_OPTS=-Xms512m -Xmx512m" 13 | - http.cors.enabled=true 14 | - http.cors.allow-origin="*" 15 | - discovery.type=single-node 16 | ulimits: 17 | memlock: 18 | soft: -1 19 | hard: -1 20 | volumes: 21 | - ./elasticsearch_data:/usr/share/elasticsearch/data 22 | ports: 23 | - 9200:9200 24 | networks: 25 | - observability 26 | 27 | kibana: 28 | image: docker.elastic.co/kibana/kibana:7.13.0 29 | container_name: kibana 30 | ports: 31 | - 5601:5601 32 | environment: 33 | ELASTICSEARCH_URL: http://elasticsearch:9200 34 | ELASTICSEARCH_HOSTS: '["http://elasticsearch:9200"]' 35 | networks: 36 | - observability 37 | 38 | metricbeat: 39 | image: docker.elastic.co/beats/metricbeat:7.13.0 40 | container_name: metricbeat 41 | user: root 42 | volumes: 43 | - /var/run/docker.sock:/var/run/docker.sock 44 | - ./beats/metric/metricbeat.yml:/usr/share/metricbeat/metricbeat.yml 45 | restart: on-failure 46 | networks: 47 | - observability 48 | 49 | heartbeat: 50 | image: docker.elastic.co/beats/heartbeat:7.13.0 51 | container_name: heartbeat 52 | volumes: 53 | - ./beats/heartbeat/heartbeat.yml:/usr/share/heartbeat/heartbeat.yml 54 | environment: 55 | - setup.kibana.host=kibana:5601 56 | networks: 57 | - observability 58 | 59 | apm: 60 | image: docker.elastic.co/apm/apm-server-oss:7.13.0 61 | container_name: apm 62 | volumes: 63 | - ./apm/apm-server.yml:/usr/share/apm-server/apm-server.yml 64 | ports: 65 | - "8200:8200" 66 | restart: on-failure 67 | networks: 68 | - observability 69 | 70 | networks: 71 | observability: 72 | external: true -------------------------------------------------------------------------------- /nginx/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:latest 2 | RUN rm -f /var/log/nginx/access.log && rm -f /var/log/nginx/error.log 3 | COPY default.conf /etc/nginx/conf.d/default.conf 4 | 5 | RUN curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.13.0-amd64.deb && \ 6 | dpkg -i filebeat-7.13.0-amd64.deb 7 | 8 | COPY filebeat.yml /etc/filebeat/filebeat.yml 9 | COPY entrypoint.sh /entrypoint.sh 10 | RUN chmod +x entrypoint.sh 11 | ENTRYPOINT [ "/entrypoint.sh" ] -------------------------------------------------------------------------------- /nginx/default.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | location / { 4 | proxy_pass http://app:8000; 5 | } 6 | error_log /var/log/nginx/error.log error; 7 | } -------------------------------------------------------------------------------- /nginx/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | /docker-entrypoint.sh 4 | filebeat modules enable nginx 5 | filebeat setup 6 | service filebeat start 7 | nginx -g 'daemon off;' -------------------------------------------------------------------------------- /nginx/filebeat.yml: -------------------------------------------------------------------------------- 1 | ###################### Filebeat Configuration Example ######################### 2 | 3 | # This file is an example configuration file highlighting only the most common 4 | # options. The filebeat.reference.yml file from the same directory contains all the 5 | # supported options with more comments. You can use it as a reference. 6 | # 7 | # You can find the full configuration reference here: 8 | # https://www.elastic.co/guide/en/beats/filebeat/index.html 9 | 10 | # For more available modules and options, please see the filebeat.reference.yml sample 11 | # configuration file. 12 | 13 | # ============================== Filebeat inputs =============================== 14 | 15 | filebeat.inputs: 16 | 17 | # Each - is an input. Most options can be set at the input level, so 18 | # you can use different inputs for various configurations. 19 | # Below are the input specific configurations. 20 | 21 | - type: log 22 | 23 | # Change to true to enable this input configuration. 24 | enabled: false 25 | 26 | # Paths that should be crawled and fetched. Glob based paths. 27 | paths: 28 | - /var/log/*.log 29 | #- c:\programdata\elasticsearch\logs\* 30 | 31 | # Exclude lines. A list of regular expressions to match. It drops the lines that are 32 | # matching any regular expression from the list. 33 | #exclude_lines: ['^DBG'] 34 | 35 | # Include lines. A list of regular expressions to match. It exports the lines that are 36 | # matching any regular expression from the list. 37 | #include_lines: ['^ERR', '^WARN'] 38 | 39 | # Exclude files. A list of regular expressions to match. Filebeat drops the files that 40 | # are matching any regular expression from the list. By default, no files are dropped. 41 | #exclude_files: ['.gz$'] 42 | 43 | # Optional additional fields. These fields can be freely picked 44 | # to add additional information to the crawled log files for filtering 45 | #fields: 46 | # level: debug 47 | # review: 1 48 | 49 | ### Multiline options 50 | 51 | # Multiline can be used for log messages spanning multiple lines. This is common 52 | # for Java Stack Traces or C-Line Continuation 53 | 54 | # The regexp Pattern that has to be matched. The example pattern matches all lines starting with [ 55 | #multiline.pattern: ^\[ 56 | 57 | # Defines if the pattern set under pattern should be negated or not. Default is false. 58 | #multiline.negate: false 59 | 60 | # Match can be set to "after" or "before". It is used to define if lines should be append to a pattern 61 | # that was (not) matched before or after or as long as a pattern is not matched based on negate. 62 | # Note: After is the equivalent to previous and before is the equivalent to to next in Logstash 63 | #multiline.match: after 64 | 65 | # filestream is an experimental input. It is going to replace log input in the future. 66 | - type: filestream 67 | 68 | # Change to true to enable this input configuration. 69 | enabled: false 70 | 71 | # Paths that should be crawled and fetched. Glob based paths. 72 | paths: 73 | - /var/log/*.log 74 | #- c:\programdata\elasticsearch\logs\* 75 | 76 | # Exclude lines. A list of regular expressions to match. It drops the lines that are 77 | # matching any regular expression from the list. 78 | #exclude_lines: ['^DBG'] 79 | 80 | # Include lines. A list of regular expressions to match. It exports the lines that are 81 | # matching any regular expression from the list. 82 | #include_lines: ['^ERR', '^WARN'] 83 | 84 | # Exclude files. A list of regular expressions to match. Filebeat drops the files that 85 | # are matching any regular expression from the list. By default, no files are dropped. 86 | #prospector.scanner.exclude_files: ['.gz$'] 87 | 88 | # Optional additional fields. These fields can be freely picked 89 | # to add additional information to the crawled log files for filtering 90 | #fields: 91 | # level: debug 92 | # review: 1 93 | 94 | # ============================== Filebeat modules ============================== 95 | 96 | filebeat.config.modules: 97 | # Glob pattern for configuration loading 98 | path: ${path.config}/modules.d/*.yml 99 | 100 | # Set to true to enable config reloading 101 | reload.enabled: false 102 | 103 | # Period on which files under path should be checked for changes 104 | #reload.period: 10s 105 | 106 | # ======================= Elasticsearch template setting ======================= 107 | 108 | setup.template.settings: 109 | index.number_of_shards: 1 110 | #index.codec: best_compression 111 | #_source.enabled: false 112 | 113 | 114 | # ================================== General =================================== 115 | 116 | # The name of the shipper that publishes the network data. It can be used to group 117 | # all the transactions sent by a single shipper in the web interface. 118 | #name: 119 | 120 | # The tags of the shipper are included in their own field with each 121 | # transaction published. 122 | #tags: ["service-X", "web-tier"] 123 | 124 | # Optional fields that you can specify to add additional information to the 125 | # output. 126 | #fields: 127 | # env: staging 128 | 129 | # ================================= Dashboards ================================= 130 | # These settings control loading the sample dashboards to the Kibana index. Loading 131 | # the dashboards is disabled by default and can be enabled either by setting the 132 | # options here or by using the `setup` command. 133 | #setup.dashboards.enabled: false 134 | 135 | # The URL from where to download the dashboards archive. By default this URL 136 | # has a value which is computed based on the Beat name and version. For released 137 | # versions, this URL points to the dashboard archive on the artifacts.elastic.co 138 | # website. 139 | #setup.dashboards.url: 140 | 141 | # =================================== Kibana =================================== 142 | 143 | # Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API. 144 | # This requires a Kibana endpoint configuration. 145 | setup.kibana: 146 | 147 | # Kibana Host 148 | # Scheme and port can be left out and will be set to the default (http and 5601) 149 | # In case you specify and additional path, the scheme is required: http://localhost:5601/path 150 | # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601 151 | host: "kibana:5601" 152 | 153 | # Kibana Space ID 154 | # ID of the Kibana Space into which the dashboards should be loaded. By default, 155 | # the Default Space will be used. 156 | #space.id: 157 | 158 | # =============================== Elastic Cloud ================================ 159 | 160 | # These settings simplify using Filebeat with the Elastic Cloud (https://cloud.elastic.co/). 161 | 162 | # The cloud.id setting overwrites the `output.elasticsearch.hosts` and 163 | # `setup.kibana.host` options. 164 | # You can find the `cloud.id` in the Elastic Cloud web UI. 165 | #cloud.id: 166 | 167 | # The cloud.auth setting overwrites the `output.elasticsearch.username` and 168 | # `output.elasticsearch.password` settings. The format is `:`. 169 | #cloud.auth: 170 | # cloud.id: "observability-deployment:dXMtZWFzdC0xLmF3cy5mb3VuZC5pbyQ4MzE2OGQ1MGUwN2U0ZmFhYTk1MjgxNzQxMTUwMzA2NSQzMGRiOWRjOTk4YTc0MGEwYjg0OThmODZhZmRjNTBiMw==" 171 | # cloud.auth: "elastic:PoFpWBdAoU9Y7kbAU64xXyyh" 172 | 173 | # ================================== Outputs =================================== 174 | 175 | # Configure what output to use when sending the data collected by the beat. 176 | 177 | # ---------------------------- Elasticsearch Output ---------------------------- 178 | output.elasticsearch: 179 | # Array of hosts to connect to. 180 | hosts: ["elasticsearch:9200"] 181 | 182 | # Protocol - either `http` (default) or `https`. 183 | #protocol: "https" 184 | 185 | # Authentication credentials - either API key or username/password. 186 | #api_key: "id:api_key" 187 | username: "elastic" 188 | password: "changeme" 189 | 190 | # ------------------------------ Logstash Output ------------------------------- 191 | #output.logstash: 192 | # The Logstash hosts 193 | #hosts: ["localhost:5044"] 194 | 195 | # Optional SSL. By default is off. 196 | # List of root certificates for HTTPS server verifications 197 | #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] 198 | 199 | # Certificate for SSL client authentication 200 | #ssl.certificate: "/etc/pki/client/cert.pem" 201 | 202 | # Client Certificate Key 203 | #ssl.key: "/etc/pki/client/cert.key" 204 | 205 | # ================================= Processors ================================= 206 | processors: 207 | - add_host_metadata: 208 | when.not.contains.tags: forwarded 209 | - add_cloud_metadata: ~ 210 | - add_docker_metadata: ~ 211 | - add_kubernetes_metadata: ~ 212 | 213 | # ================================== Logging =================================== 214 | 215 | # Sets log level. The default log level is info. 216 | # Available log levels are: error, warning, info, debug 217 | #logging.level: debug 218 | 219 | # At debug level, you can selectively enable logging only for some components. 220 | # To enable all selectors use ["*"]. Examples of other selectors are "beat", 221 | # "publisher", "service". 222 | #logging.selectors: ["*"] 223 | 224 | # ============================= X-Pack Monitoring ============================== 225 | # Filebeat can export internal metrics to a central Elasticsearch monitoring 226 | # cluster. This requires xpack monitoring to be enabled in Elasticsearch. The 227 | # reporting is disabled by default. 228 | 229 | # Set to true to enable the monitoring reporter. 230 | #monitoring.enabled: false 231 | 232 | # Sets the UUID of the Elasticsearch cluster under which monitoring data for this 233 | # Filebeat instance will appear in the Stack Monitoring UI. If output.elasticsearch 234 | # is enabled, the UUID is derived from the Elasticsearch cluster referenced by output.elasticsearch. 235 | #monitoring.cluster_uuid: 236 | 237 | # Uncomment to send the metrics to Elasticsearch. Most settings from the 238 | # Elasticsearch output are accepted here as well. 239 | # Note that the settings should point to your Elasticsearch *monitoring* cluster. 240 | # Any setting that is not set is automatically inherited from the Elasticsearch 241 | # output configuration, so if you have the Elasticsearch output configured such 242 | # that it is pointing to your Elasticsearch monitoring cluster, you can simply 243 | # uncomment the following line. 244 | #monitoring.elasticsearch: 245 | 246 | # ============================== Instrumentation =============================== 247 | 248 | # Instrumentation support for the filebeat. 249 | #instrumentation: 250 | # Set to true to enable instrumentation of filebeat. 251 | #enabled: false 252 | 253 | # Environment in which filebeat is running on (eg: staging, production, etc.) 254 | #environment: "" 255 | 256 | # APM Server hosts to report instrumentation results to. 257 | #hosts: 258 | # - http://localhost:8200 259 | 260 | # API Key for the APM Server(s). 261 | # If api_key is set then secret_token will be ignored. 262 | #api_key: 263 | 264 | # Secret token for the APM Server(s). 265 | #secret_token: 266 | 267 | 268 | # ================================= Migration ================================== 269 | 270 | # This allows to enable 6.7 migration aliases 271 | #migration.6_to_7.enabled: true 272 | 273 | --------------------------------------------------------------------------------