diff --git a/.ci/apm-beats-update.groovy b/.ci/apm-beats-update.groovy new file mode 100644 index 00000000000..39572aa8d28 --- /dev/null +++ b/.ci/apm-beats-update.groovy @@ -0,0 +1,107 @@ +#!/usr/bin/env groovy +@Library('apm@current') _ + +pipeline { + agent { label 'linux && immutable' } + environment { + REPO = 'apm-server' + BASE_DIR = "src/github.com/elastic/${env.REPO}" + NOTIFY_TO = credentials('notify-to') + GITHUB_CHECK_ITS_NAME = 'APM Server Beats update' + PATH = "${env.PATH}:${env.WORKSPACE}/bin" + HOME = "${env.WORKSPACE}" + GOPATH = "${env.WORKSPACE}" + } + options { + timeout(time: 2, unit: 'HOURS') + buildDiscarder(logRotator(numToKeepStr: '100', artifactNumToKeepStr: '30', daysToKeepStr: '30')) + timestamps() + ansiColor('xterm') + disableResume() + durabilityHint('PERFORMANCE_OPTIMIZED') + rateLimitBuilds(throttle: [count: 60, durationName: 'hour', userBoost: true]) + quietPeriod(10) + } + triggers { + issueCommentTrigger('(?i).*/run\\s+(?:apm-beats-update\\W+)?.*') + } + stages { + /** + Checkout the code and stash it, to use it on other stages. + */ + stage('Checkout') { + options { skipDefaultCheckout() } + steps { + deleteDir() + gitCheckout(basedir: "beats") + script { + dir("beats"){ + env.GO_VERSION = readFile(".go-version").trim() + def regexps =[ + "^devtools/mage.*", + "^libbeat/scripts/Makefile", + ] + env.BEATS_UPDATED = isGitRegionMatch(patterns: regexps) + + // Skip all the stages except docs for PR's with asciidoc changes only + env.ONLY_DOCS = isGitRegionMatch(patterns: [ '.*\\.asciidoc' ], comparator: 'regexp', shouldMatchAll: true) + } + } + } + } + /** + updates beats updates the framework part and go parts of beats. + Then build and test. + Finally archive the results. + */ + stage('Update Beats') { + options { skipDefaultCheckout() } + when { + beforeAgent true + anyOf { + branch 'master' + branch "\\d+\\.\\d+" + branch "v\\d?" + tag "v\\d+\\.\\d+\\.\\d+*" + allOf { + expression { return env.BEATS_UPDATED != "false" || isCommentTrigger() } + changeRequest() + } + + } + } + steps { + withGithubNotify(context: 'Check Apm Server Beats Update') { + deleteDir() + gitCheckout(basedir: "${BASE_DIR}", + repo: "git@github.com:elastic/${REPO}.git", + branch: 'master', + credentialsId: 'credentials-id', + githubNotifyFirstTimeContributor: false, + depth: 1, + reference: "/var/lib/jenkins/.git-references/${REPO}.git" + ) + dir("${BASE_DIR}"){ + sh(label: 'Update Beats script', script: """ + export BEATS_VERSION=${env.GIT_BASE_COMMIT} + git config --global --add remote.origin.fetch "+refs/pull/*/head:refs/remotes/origin/pr/*" + script/jenkins/update-beats.sh + """) + } + } + } + post { + always { + catchError(buildResult: 'SUCCESS', message: 'Failed to grab test results tar files', stageResult: 'SUCCESS') { + tar(file: "update-beats-system-tests-linux-files.tgz", archive: true, dir: "system-tests", pathPrefix: "${BASE_DIR}/build") + } + } + } + } + } + post { + cleanup { + notifyBuildResult() + } + } +} diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index e166e9d6e47..48b127bd97d 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -38,16 +38,21 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d *Affecting all Beats* -TLS or Beats that accept connections over TLS and validate client certificates. {pull}14146[14146] +- TLS or Beats that accept connections over TLS and validate client certificates. {pull}14146[14146] +- Fix panic in the Logstash output when trying to send events to closed connection. {pull}15568[15568] +- Fix missing output in dockerlogbeat {pull}15719[15719] *Auditbeat* +- system/socket: Fixed compatibility issue with kernel 5.x. {pull}15771[15771] *Filebeat* +- Add shared_credential_file to cloudtrail config {issue}15652[15652] {pull}15656[15656] *Heartbeat* +- Fixed excessive memory usage introduced in 7.5 due to over-allocating memory for HTTP checks. {pull}15639[15639] *Journalbeat* @@ -73,102 +78,18 @@ TLS or Beats that accept connections over TLS and validate client certificates. *Filebeat* - +- Set event.outcome field based on googlecloud audit log output. {pull}15731[15731] *Heartbeat* +- Allow a list of status codes for HTTP checks. {pull}15587[15587] + *Journalbeat* *Metricbeat* -- Add AWS SQS metricset. {pull}10684[10684] {issue}10053[10053] -- Add AWS s3_request metricset. {pull}10949[10949] {issue}10055[10055] -- Add s3_daily_storage metricset. {pull}10940[10940] {issue}10055[10055] -- Add `coredns` metricbeat module. {pull}10585[10585] -- Add SSL support for Metricbeat HTTP server. {pull}11482[11482] {issue}11457[11457] -- The `elasticsearch.index` metricset (with `xpack.enabled: true`) now collects `refresh.external_total_time_in_millis` fields from Elasticsearch. {pull}11616[11616] -- Allow module configurations to have variants {pull}9118[9118] -- Add `timeseries.instance` field calculation. {pull}10293[10293] -- Added new disk states and raid level to the system/raid metricset. {pull}11613[11613] -- Added `path_name` and `start_name` to service metricset on windows module {issue}8364[8364] {pull}11877[11877] -- Add check on object name in the counter path if the instance name is missing {issue}6528[6528] {pull}11878[11878] -- Add AWS cloudwatch metricset. {pull}11798[11798] {issue}11734[11734] -- Add `regions` in aws module config to specify target regions for querying cloudwatch metrics. {issue}11932[11932] {pull}11956[11956] -- Keep `etcd` followers members from reporting `leader` metricset events {pull}12004[12004] -- Add overview dashboard to Consul module {pull}10665[10665] -- New fields were added in the mysql/status metricset. {pull}12227[12227] -- Add Kubernetes metricset `proxy`. {pull}12312[12312] -- Add Kubernetes proxy dashboard to Kubernetes module {pull}12734[12734] -- Always report Pod UID in the `pod` metricset. {pull}12345[12345] -- Add Vsphere Virtual Machine operating system to `os` field in Vsphere virtualmachine module. {pull}12391[12391] -- Add validation for elasticsearch and kibana modules' metricsets when xpack.enabled is set to true. {pull}12386[12386] -- Add CockroachDB module. {pull}12467[12467] -- Add support for metricbeat modules based on existing modules (a.k.a. light modules) {issue}12270[12270] {pull}12465[12465] -- Add a system/entropy metricset {pull}12450[12450] -- Add kubernetes metricset `controllermanager` {pull}12409[12409] -- Add Kubernetes controller manager dashboard to Kubernetes module {pull}12744[12744] -- Allow redis URL format in redis hosts config. {pull}12408[12408] -- Add tags into ec2 metricset. {issue}[12263]12263 {pull}12372[12372] -- Add metrics to kubernetes apiserver metricset. {pull}12922[12922] -- Add kubernetes metricset `scheduler` {pull}12521[12521] -- Add Kubernetes scheduler dashboard to Kubernetes module {pull}12749[12749] -- Add `beat` module. {pull}12181[12181] {pull}12615[12615] -- Collect tags for cloudwatch metricset in aws module. {issue}[12263]12263 {pull}12480[12480] -- Add AWS RDS metricset. {pull}11620[11620] {issue}10054[10054] -- Add Oracle Module {pull}11890[11890] -- Add Oracle Tablespaces Dashboard {pull}12736[12736] -- Collect client provided name for rabbitmq connection. {issue}12851[12851] {pull}12852[12852] -- Add support to load default aws config file to get credentials. {pull}12727[12727] {issue}12708[12708] -- Add statistic option into cloudwatch metricset. {issue}12370[12370] {pull}12840[12840] -- Add support for kubernetes cronjobs {pull}13001[13001] -- Add cgroup memory stats to docker/memory metricset {pull}12916[12916] -- Add AWS elb metricset. {pull}12952[12952] {issue}11701[11701] -- Add AWS ebs metricset. {pull}13167[13167] {issue}11699[11699] -- Add `metricset.period` field with the configured fetching period. {pull}13242[13242] {issue}12616[12616] -- Add rate metrics for ec2 metricset. {pull}13203[13203] -- Add refresh list of perf counters at every fetch {issue}13091[13091] -- Add Performance metricset to Oracle module {pull}12547[12547] -- Add proc/vmstat data to the system/memory metricset on linux {pull}13322[13322] -- Use DefaultMetaGeneratorConfig in MetadataEnrichers to initialize configurations {pull}13414[13414] -- Add module for statsd. {pull}13109[13109] -- Add support for NATS version 2. {pull}13601[13601] -- Add `docker.cpu.*.norm.pct` metrics for `cpu` metricset of Docker Metricbeat module. {pull}13695[13695] -- Add `instance` label by default when using Prometheus collector. {pull}13737[13737] -- Add azure module. {pull}13196[13196] {pull}13859[13859] {pull}13988[13988] -- Add Apache Tomcat module {pull}13491[13491] -- Add ECS `container.id` and `container.runtime` to kubernetes `state_container` metricset. {pull}13884[13884] -- Add `job` label by default when using Prometheus collector. {pull}13878[13878] -- Add `state_resourcequota` metricset for Kubernetes module. {pull}13693[13693] -- Add tags filter in ec2 metricset. {pull}13872[13872] {issue}13145[13145] -- Add cloud.account.id and cloud.account.name into events from aws module. {issue}13551[13551] {pull}13558[13558] -- Add `metrics_path` as known hint for autodiscovery {pull}13996[13996] -- Leverage KUBECONFIG when creating k8s client. {pull}13916[13916] -- Add ability to filter by tags for cloudwatch metricset. {pull}13758[13758] {issue}13145[13145] -- Release cloudwatch, s3_daily_storage, s3_request, sqs and rds metricset as GA. {pull}14114[14114] {issue}14059[14059] -- Add Oracle overview dashboard {pull}14021[14021] -- Release CoreDNS module as GA. {pull}14308[14308] -- Release CouchDB module as GA. {pull}14300[14300] -- Add `elasticsearch/enrich` metricset. {pull}14243[14243] {issue}14221[14221] -- Add support for Application ELB and Network ELB. {pull}14123[14123] {issue}13538[13538] {issue}13539[13539] -- Release aws ebs metricset as GA. {pull}14312[14312] {issue}14060[14060] -- Add `connection.state` field for RabbitMQ module. {pull}13981[13981] -- Add more TCP states to Metricbeat system socket_summary. {pull}14347[14347] -- Add Kafka JMX metricsets. {pull}14330[14330] -- Add metrics to envoyproxy server metricset and support for envoy proxy 1.12. {pull}14416[14416] {issue}13642[13642] -- Release kubernetes modules `controllermanager`, `scheduler`, `proxy`, `state_cronjob` and `state_resourcequota` as GA. {pull}14584[14584] -- Add module for ActiveMQ. {pull}14580[14580] -- Enable script processor. {pull}14711[14711] -- Enable wildcard for cloudwatch metricset namespace. {pull}14971[14971] {issue}14965[14965] -- Add `kube-state-metrics` `state_service` metrics for kubernetes module. {pull}14794[14794] -- Add `kube-state-metrics` `state_persistentvolume` metrics for kubernetes module. {pull}14859[14859] -- Add `kube-state-metrics` `state_persistentvolumeclaim` metrics for kubernetes module. {pull}15066[15066] -- Add usage metricset in aws modules. {pull}14925[14925] {issue}14935[14935] -- Add billing metricset in aws modules. {pull}14801[14801] {issue}14934[14934] -- Add AWS SNS metricset. {pull}14946[14946] -- Add overview dashboard for AWS SNS module {pull}14977[14977] -- Add `index` option to all modules to specify a module-specific output index. {pull}15100[15100] -- Add a `system/service` metricset for systemd data. {pull}14206[14206] +- Move the windows pdh implementation from perfmon to a shared location in order for future modules/metricsets to make use of. {pull}15503[15503] - Add lambda metricset in aws module. {pull}15260[15260] - Expand data for the `system/memory` metricset {pull}15492[15492] - Add azure `storage` metricset in order to retrieve metric values for storage accounts. {issue}14548[14548] {pull}15342[15342] @@ -176,6 +97,8 @@ TLS or Beats that accept connections over TLS and validate client certificates. - Add DynamoDB AWS Metricbeat light module {pull}15097[15097] - Release elb module as GA. {pull}15485[15485] - Add a `system/network_summary` metricset {pull}15196[15196] +- Add mesh metricset for Istio Metricbeat module{pull}15535[15535] +- Make the `system/cpu` metricset collect normalized CPU metrics by default. {issue}15618[15618] {pull}15729[15729] *Packetbeat* diff --git a/Jenkinsfile b/Jenkinsfile index 89753eec3e2..3eb0d1ff7dd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,11 +1,6 @@ #!/usr/bin/env groovy -library identifier: 'apm@master', -retriever: modernSCM( - [$class: 'GitSCMSource', - credentialsId: 'f94e9298-83ae-417e-ba91-85c279771570', - id: '37cf2c00-2cc7-482e-8c62-7bbffef475e2', - remote: 'git@github.com:elastic/apm-pipeline-library.git']) +@Library('apm@current') _ pipeline { agent { label 'ubuntu && immutable' } @@ -36,12 +31,7 @@ pipeline { stage('Checkout') { options { skipDefaultCheckout() } steps { - //TODO we need to configure the library in Jenkins to use privileged methods. - //gitCheckout(basedir: "${BASE_DIR}") - dir("${BASE_DIR}"){ - checkout scm - githubEnv() - } + gitCheckout(basedir: "${BASE_DIR}") stash allowEmpty: true, name: 'source', useDefaultExcludes: false script { env.GO_VERSION = readFile("${BASE_DIR}/.go-version").trim() diff --git a/NOTICE.txt b/NOTICE.txt index f61138aaf82..5e3a26acd96 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -2099,6 +2099,239 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +-------------------------------------------------------------------- +Dependency: github.com/godror/godror +Version: v0.10.4 +Revision: 0123d49bd73e1bed106ac8b6af67f943fbbf06e2 +License type (autodetected): Apache-2.0 +./vendor/github.com/godror/godror/LICENSE.md: +-------------------------------------------------------------------- +Apache License 2.0 + + +-------------------------------------------------------------------- +Dependency: github.com/godror/godror/odpi +License type (autodetected): UPL-1.0 +./vendor/github.com/godror/godror/odpi/LICENSE.md: +-------------------------------------------------------------------- +Copyright (c) 2016, 2018 Oracle and/or its affiliates. All rights reserved. + +This program is free software: you can modify it and/or redistribute it under +the terms of: + +(i) the Universal Permissive License v 1.0 or at your option, any + later version (); and/or + +(ii) the Apache License v 2.0. () + + +The Universal Permissive License (UPL), Version 1.0 +=================================================== + +Subject to the condition set forth below, permission is hereby granted to any +person obtaining a copy of this software, associated documentation and/or data +(collectively the "Software"), free of charge and under any and all copyright +rights in the Software, and any and all patent rights owned or freely +licensable by each licensor hereunder covering either (i) the unmodified +Software as contributed to or provided by such licensor, or (ii) the Larger +Works (as defined below), to deal in both + +(a) the Software, and + +(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + one is included with the Software (each a "Larger Work" to which the + Software is contributed by such licensors), + +without restriction, including without limitation the rights to copy, create +derivative works of, display, perform, and distribute the Software and make, +use, sell, offer for sale, import, export, have made, and have sold the +Software and the Larger Work(s), and to sublicense the foregoing rights on +either these or other terms. + +This license is subject to the following condition: + +The above copyright notice and either this complete permission notice or at a +minimum a reference to the UPL must be included in all copies or substantial +portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +Apache License +============== + +Version 2.0, January 2004 + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. **Definitions**. + + "License" shall mean the terms and conditions for use, reproduction, and + distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by the + copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all other + entities that control, are controlled by, or are under common control with + that entity. For the purposes of this definition, "control" means (i) the + power, direct or indirect, to cause the direction or management of such + entity, whether by contract or otherwise, or (ii) ownership of fifty + percent (50%) or more of the outstanding shares, or (iii) beneficial + ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity exercising + permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation source, + and configuration files. + + "Object" form shall mean any form resulting from mechanical transformation + or translation of a Source form, including but not limited to compiled + object code, generated documentation, and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or Object form, + made available under the License, as indicated by a copyright notice that + is included in or attached to the work (an example is provided in the + Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object form, + that is based on (or derived from) the Work and for which the editorial + revisions, annotations, elaborations, or other modifications represent, as + a whole, an original work of authorship. For the purposes of this License, + Derivative Works shall not include works that remain separable from, or + merely link (or bind by name) to the interfaces of, the Work and Derivative + Works thereof. + + "Contribution" shall mean any work of authorship, including the original + version of the Work and any modifications or additions to that Work or + Derivative Works thereof, that is intentionally submitted to Licensor for + inclusion in the Work by the copyright owner or by an individual or Legal + Entity authorized to submit on behalf of the copyright owner. For the + purposes of this definition, "submitted" means any form of electronic, + verbal, or written communication sent to the Licensor or its + representatives, including but not limited to communication on electronic + mailing lists, source code control systems, and issue tracking systems that + are managed by, or on behalf of, the Licensor for the purpose of discussing + and improving the Work, but excluding communication that is conspicuously + marked or otherwise designated in writing by the copyright owner as "Not a + Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity on + behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. **Grant of Copyright License.** Subject to the terms and conditions of this + License, each Contributor hereby grants to You a perpetual, worldwide, + non-exclusive, no-charge, royalty-free, irrevocable copyright license to + reproduce, prepare Derivative Works of, publicly display, publicly perform, + sublicense, and distribute the Work and such Derivative Works in Source or + Object form. + +3. **Grant of Patent License.** Subject to the terms and conditions of this + License, each Contributor hereby grants to You a perpetual, worldwide, + non-exclusive, no-charge, royalty-free, irrevocable (except as stated in + this section) patent license to make, have made, use, offer to sell, sell, + import, and otherwise transfer the Work, where such license applies only to + those patent claims licensable by such Contributor that are necessarily + infringed by their Contribution(s) alone or by combination of their + Contribution(s) with the Work to which such Contribution(s) was submitted. + If You institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work or a + Contribution incorporated within the Work constitutes direct or + contributory patent infringement, then any patent licenses granted to You + under this License for that Work shall terminate as of the date such + litigation is filed. + +4. **Redistribution.** You may reproduce and distribute copies of the Work or + Derivative Works thereof in any medium, with or without modifications, and + in Source or Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works a + copy of this License; and + + 2. You must cause any modified files to carry prominent notices stating + that You changed the files; and + + 3. You must retain, in the Source form of any Derivative Works that You + distribute, all copyright, patent, trademark, and attribution notices + from the Source form of the Work, excluding those notices that do not + pertain to any part of the Derivative Works; and + + 4. If the Work includes a "NOTICE" text file as part of its distribution, + then any Derivative Works that You distribute must include a readable + copy of the attribution notices contained within such NOTICE file, + excluding those notices that do not pertain to any part of the + Derivative Works, in at least one of the following places: within a + NOTICE text file distributed as part of the Derivative Works; within + the Source form or documentation, if provided along with the Derivative + Works; or, within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents of the + NOTICE file are for informational purposes only and do not modify the + License. You may add Your own attribution notices within Derivative + Works that You distribute, alongside or as an addendum to the NOTICE + text from the Work, provided that such additional attribution notices + cannot be construed as modifying the License. + + You may add Your own copyright statement to Your modifications and may + provide additional or different license terms and conditions for use, + reproduction, or distribution of Your modifications, or for any such + Derivative Works as a whole, provided Your use, reproduction, and + distribution of the Work otherwise complies with the conditions stated + in this License. + +5. **Submission of Contributions.** Unless You explicitly state otherwise, any + Contribution intentionally submitted for inclusion in the Work by You to + the Licensor shall be under the terms and conditions of this License, + without any additional terms or conditions. Notwithstanding the above, + nothing herein shall supersede or modify the terms of any separate license + agreement you may have executed with Licensor regarding such Contributions. + +6. **Trademarks.** This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, except + as required for reasonable and customary use in describing the origin of + the Work and reproducing the content of the NOTICE file. + +7. **Disclaimer of Warranty.** Unless required by applicable law or agreed to + in writing, Licensor provides the Work (and each Contributor provides its + Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied, including, without limitation, any + warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or + FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for + determining the appropriateness of using or redistributing the Work and + assume any risks associated with Your exercise of permissions under this + License. + +8. **Limitation of Liability.** In no event and under no legal theory, whether + in tort (including negligence), contract, or otherwise, unless required by + applicable law (such as deliberate and grossly negligent acts) or agreed to + in writing, shall any Contributor be liable to You for damages, including + any direct, indirect, special, incidental, or consequential damages of any + character arising as a result of this License or out of the use or + inability to use the Work (including but not limited to damages for loss of + goodwill, work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor has been + advised of the possibility of such damages. + +9. **Accepting Warranty or Additional Liability.** While redistributing the + Work or Derivative Works thereof, You may choose to offer, and charge a fee + for, acceptance of support, warranty, indemnity, or other liability + obligations and/or rights consistent with this License. However, in + accepting such obligations, You may act only on Your own behalf and on Your + sole responsibility, not on behalf of any other Contributor, and only if + You agree to indemnify, defend, and hold each Contributor harmless for any + liability incurred by, or claims asserted against, such Contributor by + reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + -------------------------------------------------------------------- Dependency: github.com/gofrs/flock Revision: 5135e617513b1e6e205a3a89b042249dee6730c8 @@ -6127,10 +6360,44 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +-------------------------------------------------------------------- +Dependency: golang.org/x/xerrors +Revision: 9bdfabe68543c54f90421aeb9a60ef8061b5b544 +License type (autodetected): BSD-3-Clause +./vendor/golang.org/x/xerrors/LICENSE: +-------------------------------------------------------------------- +Copyright (c) 2019 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + -------------------------------------------------------------------- Dependency: google.golang.org/api -Version: v0.14.0 -Revision: 8a410c21381766a810817fd6200fce8838ecb277 +Version: v0.7.0 +Revision: 02490b97dff7cfde1995bd77de808fd27053bc87 License type (autodetected): BSD-3-Clause ./vendor/google.golang.org/api/LICENSE: -------------------------------------------------------------------- @@ -6252,239 +6519,6 @@ License type (autodetected): Apache-2.0 Apache License 2.0 --------------------------------------------------------------------- -Dependency: gopkg.in/goracle.v2 -Revision: 3222d7159b45fce95150f06a57e1bcc2868108d3 -License type (autodetected): Apache-2.0 -./vendor/gopkg.in/goracle.v2/LICENSE.md: --------------------------------------------------------------------- -Apache License 2.0 - - --------------------------------------------------------------------- -Dependency: gopkg.in/goracle.v2/odpi -License type (autodetected): UPL-1.0 -./vendor/gopkg.in/goracle.v2/odpi/LICENSE.md: --------------------------------------------------------------------- -Copyright (c) 2016, 2018 Oracle and/or its affiliates. All rights reserved. - -This program is free software: you can modify it and/or redistribute it under -the terms of: - -(i) the Universal Permissive License v 1.0 or at your option, any - later version (); and/or - -(ii) the Apache License v 2.0. () - - -The Universal Permissive License (UPL), Version 1.0 -=================================================== - -Subject to the condition set forth below, permission is hereby granted to any -person obtaining a copy of this software, associated documentation and/or data -(collectively the "Software"), free of charge and under any and all copyright -rights in the Software, and any and all patent rights owned or freely -licensable by each licensor hereunder covering either (i) the unmodified -Software as contributed to or provided by such licensor, or (ii) the Larger -Works (as defined below), to deal in both - -(a) the Software, and - -(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - one is included with the Software (each a "Larger Work" to which the - Software is contributed by such licensors), - -without restriction, including without limitation the rights to copy, create -derivative works of, display, perform, and distribute the Software and make, -use, sell, offer for sale, import, export, have made, and have sold the -Software and the Larger Work(s), and to sublicense the foregoing rights on -either these or other terms. - -This license is subject to the following condition: - -The above copyright notice and either this complete permission notice or at a -minimum a reference to the UPL must be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - - -Apache License -============== - -Version 2.0, January 2004 - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. **Definitions**. - - "License" shall mean the terms and conditions for use, reproduction, and - distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by the - copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all other - entities that control, are controlled by, or are under common control with - that entity. For the purposes of this definition, "control" means (i) the - power, direct or indirect, to cause the direction or management of such - entity, whether by contract or otherwise, or (ii) ownership of fifty - percent (50%) or more of the outstanding shares, or (iii) beneficial - ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity exercising - permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation source, - and configuration files. - - "Object" form shall mean any form resulting from mechanical transformation - or translation of a Source form, including but not limited to compiled - object code, generated documentation, and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or Object form, - made available under the License, as indicated by a copyright notice that - is included in or attached to the work (an example is provided in the - Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object form, - that is based on (or derived from) the Work and for which the editorial - revisions, annotations, elaborations, or other modifications represent, as - a whole, an original work of authorship. For the purposes of this License, - Derivative Works shall not include works that remain separable from, or - merely link (or bind by name) to the interfaces of, the Work and Derivative - Works thereof. - - "Contribution" shall mean any work of authorship, including the original - version of the Work and any modifications or additions to that Work or - Derivative Works thereof, that is intentionally submitted to Licensor for - inclusion in the Work by the copyright owner or by an individual or Legal - Entity authorized to submit on behalf of the copyright owner. For the - purposes of this definition, "submitted" means any form of electronic, - verbal, or written communication sent to the Licensor or its - representatives, including but not limited to communication on electronic - mailing lists, source code control systems, and issue tracking systems that - are managed by, or on behalf of, the Licensor for the purpose of discussing - and improving the Work, but excluding communication that is conspicuously - marked or otherwise designated in writing by the copyright owner as "Not a - Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity on - behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. **Grant of Copyright License.** Subject to the terms and conditions of this - License, each Contributor hereby grants to You a perpetual, worldwide, - non-exclusive, no-charge, royalty-free, irrevocable copyright license to - reproduce, prepare Derivative Works of, publicly display, publicly perform, - sublicense, and distribute the Work and such Derivative Works in Source or - Object form. - -3. **Grant of Patent License.** Subject to the terms and conditions of this - License, each Contributor hereby grants to You a perpetual, worldwide, - non-exclusive, no-charge, royalty-free, irrevocable (except as stated in - this section) patent license to make, have made, use, offer to sell, sell, - import, and otherwise transfer the Work, where such license applies only to - those patent claims licensable by such Contributor that are necessarily - infringed by their Contribution(s) alone or by combination of their - Contribution(s) with the Work to which such Contribution(s) was submitted. - If You institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work or a - Contribution incorporated within the Work constitutes direct or - contributory patent infringement, then any patent licenses granted to You - under this License for that Work shall terminate as of the date such - litigation is filed. - -4. **Redistribution.** You may reproduce and distribute copies of the Work or - Derivative Works thereof in any medium, with or without modifications, and - in Source or Object form, provided that You meet the following conditions: - - 1. You must give any other recipients of the Work or Derivative Works a - copy of this License; and - - 2. You must cause any modified files to carry prominent notices stating - that You changed the files; and - - 3. You must retain, in the Source form of any Derivative Works that You - distribute, all copyright, patent, trademark, and attribution notices - from the Source form of the Work, excluding those notices that do not - pertain to any part of the Derivative Works; and - - 4. If the Work includes a "NOTICE" text file as part of its distribution, - then any Derivative Works that You distribute must include a readable - copy of the attribution notices contained within such NOTICE file, - excluding those notices that do not pertain to any part of the - Derivative Works, in at least one of the following places: within a - NOTICE text file distributed as part of the Derivative Works; within - the Source form or documentation, if provided along with the Derivative - Works; or, within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents of the - NOTICE file are for informational purposes only and do not modify the - License. You may add Your own attribution notices within Derivative - Works that You distribute, alongside or as an addendum to the NOTICE - text from the Work, provided that such additional attribution notices - cannot be construed as modifying the License. - - You may add Your own copyright statement to Your modifications and may - provide additional or different license terms and conditions for use, - reproduction, or distribution of Your modifications, or for any such - Derivative Works as a whole, provided Your use, reproduction, and - distribution of the Work otherwise complies with the conditions stated - in this License. - -5. **Submission of Contributions.** Unless You explicitly state otherwise, any - Contribution intentionally submitted for inclusion in the Work by You to - the Licensor shall be under the terms and conditions of this License, - without any additional terms or conditions. Notwithstanding the above, - nothing herein shall supersede or modify the terms of any separate license - agreement you may have executed with Licensor regarding such Contributions. - -6. **Trademarks.** This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, except - as required for reasonable and customary use in describing the origin of - the Work and reproducing the content of the NOTICE file. - -7. **Disclaimer of Warranty.** Unless required by applicable law or agreed to - in writing, Licensor provides the Work (and each Contributor provides its - Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied, including, without limitation, any - warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or - FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for - determining the appropriateness of using or redistributing the Work and - assume any risks associated with Your exercise of permissions under this - License. - -8. **Limitation of Liability.** In no event and under no legal theory, whether - in tort (including negligence), contract, or otherwise, unless required by - applicable law (such as deliberate and grossly negligent acts) or agreed to - in writing, shall any Contributor be liable to You for damages, including - any direct, indirect, special, incidental, or consequential damages of any - character arising as a result of this License or out of the use or - inability to use the Work (including but not limited to damages for loss of - goodwill, work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor has been - advised of the possibility of such damages. - -9. **Accepting Warranty or Additional Liability.** While redistributing the - Work or Derivative Works thereof, You may choose to offer, and charge a fee - for, acceptance of support, warranty, indemnity, or other liability - obligations and/or rights consistent with this License. However, in - accepting such obligations, You may act only on Your own behalf and on Your - sole responsibility, not on behalf of any other Contributor, and only if - You agree to indemnify, defend, and hold each Contributor harmless for any - liability incurred by, or claims asserted against, such Contributor by - reason of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - - -------------------------------------------------------------------- Dependency: gopkg.in/inf.v0 Revision: 3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4 diff --git a/auditbeat/auditbeat.reference.yml b/auditbeat/auditbeat.reference.yml index 33b81cc0edf..cf1b6de5c40 100644 --- a/auditbeat/auditbeat.reference.yml +++ b/auditbeat/auditbeat.reference.yml @@ -485,9 +485,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # List of root certificates for HTTPS server verifications #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] @@ -577,9 +577,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -750,9 +750,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Certificate for SSL client authentication #ssl.certificate: "/etc/pki/client/cert.pem" @@ -862,9 +862,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -1087,7 +1087,7 @@ setup.template.settings: #setup.ilm.pattern: "{now/d}-000001" # Set the lifecycle policy name. The default policy name is -# 'auditbeat-%{[agent.version]}'. +# 'auditbeat'. #setup.ilm.policy_name: "mypolicy" # The path to a JSON file that contains a lifecycle policy configuration. Used @@ -1131,9 +1131,9 @@ setup.kibana: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -1307,9 +1307,9 @@ logging.files: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -1337,6 +1337,14 @@ logging.files: #metrics.period: 10s #state.period: 1m +# The `monitoring.cloud.id` setting overwrites the `monitoring.elasticsearch.hosts` +# setting. You can find the value for this setting in the Elastic Cloud web UI. +#monitoring.cloud.id: + +# The `monitoring.cloud.auth` setting overwrites the `monitoring.elasticsearch.username` +# and `monitoring.elasticsearch.password` settings. The format is `:`. +#monitoring.cloud.auth: + #================================ HTTP Endpoint ====================================== # Each beat can expose internal metrics through a HTTP endpoint. For security # reasons the endpoint is disabled by default. This feature is currently experimental. diff --git a/auditbeat/docs/auditbeat-options.asciidoc b/auditbeat/docs/auditbeat-options.asciidoc new file mode 100644 index 00000000000..8233f79cee1 --- /dev/null +++ b/auditbeat/docs/auditbeat-options.asciidoc @@ -0,0 +1,56 @@ +////////////////////////////////////////////////////////////////////////// +//// This content is shared by all Auditbeat modules. Make sure you keep the +//// descriptions generic enough to work for all modules. To include +//// this file, use: +//// +//// include::{docdir}/auditbeat-options.asciidoc[] +//// +////////////////////////////////////////////////////////////////////////// + +[id="module-standard-options-{modulename}"] +[float] +==== Standard configuration options + +You can specify the following options for any {beatname_uc} module. + +*`module`*:: The name of the module to run. + +ifeval::["{modulename}"=="system"] +*`datasets`*:: A list of datasets to execute. +endif::[] + +*`enabled`*:: A Boolean value that specifies whether the module is enabled. + +ifeval::["{modulename}"=="system"] +*`period`*:: The frequency at which the datasets check for changes. If a system +is not reachable, {beatname_uc} returns an error for each period. This setting +is required. For most datasets, especially `process` and `socket`, a shorter +period is recommended. +endif::[] + +*`fields`*:: A dictionary of fields that will be sent with the dataset event. This setting +is optional. + +*`tags`*:: A list of tags that will be sent with the dataset event. This setting is +optional. + +*`processors`*:: A list of processors to apply to the data generated by the dataset. ++ +See <> for information about specifying +processors in your config. + +*`index`*:: If present, this formatted string overrides the index for events from this +module (for elasticsearch outputs), or sets the `raw_index` field of the event's +metadata (for other outputs). This string can only refer to the agent name and +version and the event timestamp; for access to dynamic fields, use +`output.elasticsearch.index` or a processor. ++ +Example value: `"%{[agent.name]}-myindex-%{+yyyy.MM.dd}"` might +expand to +"{beatname_lc}-myindex-2019.12.13"+. + +*`keep_null`*:: If this option is set to true, fields with `null` values will be published in +the output document. By default, `keep_null` is set to `false`. + +*`service.name`*:: A name given by the user to the service the data is collected from. It can be +used for example to identify information collected from nodes of different +clusters with the same `service.type`. diff --git a/auditbeat/docs/modules/auditd.asciidoc b/auditbeat/docs/modules/auditd.asciidoc index c419c66db39..e913160d9cb 100644 --- a/auditbeat/docs/modules/auditd.asciidoc +++ b/auditbeat/docs/modules/auditd.asciidoc @@ -2,6 +2,8 @@ This file is generated! See scripts/docs_collector.py //// +:modulename: auditd + [id="{beatname_lc}-module-auditd"] == Auditd Module @@ -135,6 +137,10 @@ following example shows all configuration options with their default values. backpressure_strategy: auto ---- +This module also supports the +<> +described later. + *`socket_type`*:: This optional setting controls the type of socket that {beatname_uc} uses to receive events from the kernel. The two options are `unicast` and `multicast`. @@ -189,7 +195,8 @@ setting is primarily used for development and debugging purposes. installed to the kernel. There should be one rule per line. Comments can be embedded in the string using `#` as a prefix. The format for rules is the same used by the Linux `auditctl` utility. {beatname_uc} supports adding file watches -(`-w`) and syscall rules (`-a` or `-A`). +(`-w`) and syscall rules (`-a` or `-A`). For more information, see +<>. *`audit_rule_files`*:: A list of files to load audit rules from. This files are loaded after the rules declared in `audit_rules` are loaded. Wildcards are @@ -218,10 +225,10 @@ time. - `none`: No backpressure mitigation measures are enabled. -- -*`keep_null`*:: If this option is set to true, fields with `null` values will be -published in the output document. By default, `keep_null` is set to `false`. +include::{docdir}/auditbeat-options.asciidoc[] [float] +[[audit-rules]] === Audit rules The audit rules are where you configure the activities that are audited. These @@ -304,3 +311,6 @@ auditbeat.modules: ---- + +:modulename!: + diff --git a/auditbeat/docs/modules/file_integrity.asciidoc b/auditbeat/docs/modules/file_integrity.asciidoc index c420818cb39..42f0378de64 100644 --- a/auditbeat/docs/modules/file_integrity.asciidoc +++ b/auditbeat/docs/modules/file_integrity.asciidoc @@ -2,6 +2,8 @@ This file is generated! See scripts/docs_collector.py //// +:modulename: file_integrity + [id="{beatname_lc}-module-file_integrity"] == File Integrity Module @@ -66,6 +68,10 @@ Linux. recursive: false ---- +This module also supports the +<> +described later. + *`paths`*:: A list of paths (directories or files) to watch. Globs are not supported. The specified paths should exist when the metricset is started. @@ -122,8 +128,7 @@ of this directories are watched. If `recursive` is set to `true`, the `file_integrity` module will watch for changes on this directories and all their subdirectories. -*`keep_null`*:: If this option is set to true, fields with `null` values will be -published in the output document. By default, `keep_null` is set to `false`. +include::{docdir}/auditbeat-options.asciidoc[] [float] @@ -146,3 +151,6 @@ auditbeat.modules: ---- + +:modulename!: + diff --git a/auditbeat/module/auditd/_meta/docs.asciidoc b/auditbeat/module/auditd/_meta/docs.asciidoc index 45e3e3de934..4585b7179ff 100644 --- a/auditbeat/module/auditd/_meta/docs.asciidoc +++ b/auditbeat/module/auditd/_meta/docs.asciidoc @@ -130,6 +130,10 @@ following example shows all configuration options with their default values. backpressure_strategy: auto ---- +This module also supports the +<> +described later. + *`socket_type`*:: This optional setting controls the type of socket that {beatname_uc} uses to receive events from the kernel. The two options are `unicast` and `multicast`. @@ -184,7 +188,8 @@ setting is primarily used for development and debugging purposes. installed to the kernel. There should be one rule per line. Comments can be embedded in the string using `#` as a prefix. The format for rules is the same used by the Linux `auditctl` utility. {beatname_uc} supports adding file watches -(`-w`) and syscall rules (`-a` or `-A`). +(`-w`) and syscall rules (`-a` or `-A`). For more information, see +<>. *`audit_rule_files`*:: A list of files to load audit rules from. This files are loaded after the rules declared in `audit_rules` are loaded. Wildcards are @@ -213,10 +218,10 @@ time. - `none`: No backpressure mitigation measures are enabled. -- -*`keep_null`*:: If this option is set to true, fields with `null` values will be -published in the output document. By default, `keep_null` is set to `false`. +include::{docdir}/auditbeat-options.asciidoc[] [float] +[[audit-rules]] === Audit rules The audit rules are where you configure the activities that are audited. These diff --git a/auditbeat/module/file_integrity/_meta/docs.asciidoc b/auditbeat/module/file_integrity/_meta/docs.asciidoc index 9282b289589..372e9fc3b47 100644 --- a/auditbeat/module/file_integrity/_meta/docs.asciidoc +++ b/auditbeat/module/file_integrity/_meta/docs.asciidoc @@ -61,6 +61,10 @@ Linux. recursive: false ---- +This module also supports the +<> +described later. + *`paths`*:: A list of paths (directories or files) to watch. Globs are not supported. The specified paths should exist when the metricset is started. @@ -117,5 +121,4 @@ of this directories are watched. If `recursive` is set to `true`, the `file_integrity` module will watch for changes on this directories and all their subdirectories. -*`keep_null`*:: If this option is set to true, fields with `null` values will be -published in the output document. By default, `keep_null` is set to `false`. +include::{docdir}/auditbeat-options.asciidoc[] diff --git a/auditbeat/scripts/docs_collector.py b/auditbeat/scripts/docs_collector.py index 8c5d532ae8e..5e897bde3ed 100644 --- a/auditbeat/scripts/docs_collector.py +++ b/auditbeat/scripts/docs_collector.py @@ -44,6 +44,9 @@ def collect(base_paths): os.mkdir(os.path.join(module_docs_path(module_dir), "modules", module)) module_file = generated_note + + module_file += ":modulename: " + module + "\n\n" + module_file += "[id=\"{beatname_lc}-module-" + module + "\"]\n" with open(module_doc) as f: @@ -84,6 +87,9 @@ def collect(base_paths): module_file += "----\n\n" + # Close modulename variable + module_file += "\n:modulename!:\n\n" + module_links = "" module_includes = "" diff --git a/dev-tools/cherrypick_pr b/dev-tools/cherrypick_pr index 9b0777ce9f3..f49dd0892b1 100755 --- a/dev-tools/cherrypick_pr +++ b/dev-tools/cherrypick_pr @@ -68,6 +68,8 @@ def main(): help="Which remote to push the backport branch to") parser.add_argument("--zube-team", default="", help="Team the PR belongs to") + parser.add_argument("--keep-backport-label", action="store_true", + help="Preserve label needs_backport in original PR") args = parser.parse_args() print(args) @@ -170,8 +172,9 @@ def main(): session.post( base + "/issues/{}/labels".format(new_pr["number"]), json=labels) - # remove needs backport label from the original PR - session.delete(base + "/issues/{}/labels/needs_backport".format(args.pr_number)) + if not args.keep_backport_label: + # remove needs backport label from the original PR + session.delete(base + "/issues/{}/labels/needs_backport".format(args.pr_number)) # get version and set a version label on the original PR version = get_version(os.getcwd()) diff --git a/filebeat/docs/modules/aws.asciidoc b/filebeat/docs/modules/aws.asciidoc index f07c013b77c..d2f23e55961 100644 --- a/filebeat/docs/modules/aws.asciidoc +++ b/filebeat/docs/modules/aws.asciidoc @@ -45,8 +45,14 @@ Example config: # AWS SQS queue url #var.queue_url: https://sqs.myregion.amazonaws.com/123456/myqueue + # Filename of AWS credential file + # If not set "$HOME/.aws/credentials" is used on Linux/Mac + # "%UserProfile%\.aws\credentials" is used on Windows + # var.shared_credential_file: /etc/filebeat/aws_credentials + # Profile name for aws credential - #var.credential_profile_name: fb-aws + # If not set the default profile is used + # var.credential_profile_name: fb-aws elb: enabled: false @@ -54,8 +60,14 @@ Example config: # AWS SQS queue url #var.queue_url: https://sqs.myregion.amazonaws.com/123456/myqueue + # Filename of AWS credential file + # If not set "$HOME/.aws/credentials" is used on Linux/Mac + # "%UserProfile%\.aws\credentials" is used on Windows + # var.shared_credential_file: /etc/filebeat/aws_credentials + # Profile name for aws credential - #var.credential_profile_name: fb-aws + # If not set the default profile is used + # var.credential_profile_name: fb-aws vpcflow: enabled: false @@ -63,8 +75,14 @@ Example config: # AWS SQS queue url #var.queue_url: https://sqs.myregion.amazonaws.com/123456/myqueue + # Filename of AWS credential file + # If not set "$HOME/.aws/credentials" is used on Linux/Mac + # "%UserProfile%\.aws\credentials" is used on Windows + # var.shared_credential_file: /etc/filebeat/aws_credentials + # Profile name for aws credential - #var.credential_profile_name: fb-aws + # If not set the default profile is used + # var.credential_profile_name: fb-aws cloudtrail: enabled: false @@ -72,14 +90,24 @@ Example config: # AWS SQS queue url #var.queue_url: https://sqs.myregion.amazonaws.com/123456/myqueue + # Filename of AWS credential file + # If not set "$HOME/.aws/credentials" is used on Linux/Mac + # "%UserProfile%\.aws\credentials" is used on Windows + # var.shared_credential_file: /etc/filebeat/aws_credentials + # Profile name for aws credential - #var.credential_profile_name: fb-aws + # If not set the default profile is used + # var.credential_profile_name: fb-aws ---- *`var.queue_url`*:: AWS SQS queue url. +*`var.shared_credential_file`*:: + +Filename of AWS credential file. + *`var.credential_profile_name`*:: AWS credential profile name. diff --git a/filebeat/filebeat.reference.yml b/filebeat/filebeat.reference.yml index 80cad336d50..e0fc67776a6 100644 --- a/filebeat/filebeat.reference.yml +++ b/filebeat/filebeat.reference.yml @@ -1182,9 +1182,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # List of root certificates for HTTPS server verifications #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] @@ -1274,9 +1274,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -1447,9 +1447,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Certificate for SSL client authentication #ssl.certificate: "/etc/pki/client/cert.pem" @@ -1559,9 +1559,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -1784,7 +1784,7 @@ setup.template.settings: #setup.ilm.pattern: "{now/d}-000001" # Set the lifecycle policy name. The default policy name is -# 'filebeat-%{[agent.version]}'. +# 'filebeat'. #setup.ilm.policy_name: "mypolicy" # The path to a JSON file that contains a lifecycle policy configuration. Used @@ -1828,9 +1828,9 @@ setup.kibana: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -2004,9 +2004,9 @@ logging.files: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -2034,6 +2034,14 @@ logging.files: #metrics.period: 10s #state.period: 1m +# The `monitoring.cloud.id` setting overwrites the `monitoring.elasticsearch.hosts` +# setting. You can find the value for this setting in the Elastic Cloud web UI. +#monitoring.cloud.id: + +# The `monitoring.cloud.auth` setting overwrites the `monitoring.elasticsearch.username` +# and `monitoring.elasticsearch.password` settings. The format is `:`. +#monitoring.cloud.auth: + #================================ HTTP Endpoint ====================================== # Each beat can expose internal metrics through a HTTP endpoint. For security # reasons the endpoint is disabled by default. This feature is currently experimental. diff --git a/heartbeat/docs/heartbeat-options.asciidoc b/heartbeat/docs/heartbeat-options.asciidoc index f72e631781d..6becc27a7a9 100644 --- a/heartbeat/docs/heartbeat-options.asciidoc +++ b/heartbeat/docs/heartbeat-options.asciidoc @@ -34,7 +34,7 @@ heartbeat.monitors: - type: http schedule: '@every 5s' hosts: ["http://localhost:80/service/status"] - check.response.status: 200 + check.response.status: [200] heartbeat.scheduler: limit: 10 ---------------------------------------------------------------------- @@ -69,7 +69,7 @@ monitor definitions only, e.g. what is normally under the `heartbeat.monitors` s - type: http schedule: '@every 5s' hosts: ["http://localhost:80/service/status"] - check.response.status: 200 + check.response.status: [200] ---------------------------------------------------------------------- [float] @@ -429,7 +429,7 @@ The username for authenticating with the server. The credentials are passed with the request. This setting is optional. You need to specify credentials when your `check.response` settings require it. -For example, you can check for a 403 response (`check.response.status: 403`) +For example, you can check for a 403 response (`check.response.status: [403]`) without setting credentials. [float] @@ -489,7 +489,7 @@ Example configuration: schedule: '@every 5s' hosts: ["http://myhost:80"] check.request.method: HEAD - check.response.status: 200 + check.response.status: [200] ------------------------------------------------------------------------------- @@ -517,7 +517,7 @@ to the endpoint `/demo/add` # urlencode the body: body: "name=first&email=someemail%40someemailprovider.com" check.response: - status: 200 + status: [200] body: - Saved - saved @@ -525,14 +525,14 @@ to the endpoint `/demo/add` Under `check.response`, specify these options: -*`status`*:: The expected status code. 4xx and 5xx codes are considered `down` by default. Other codes are considered `up`. +*`status`*:: A list of expected status codes. 4xx and 5xx codes are considered `down` by default. Other codes are considered `up`. *`headers`*:: The required response headers. *`body`*:: A list of regular expressions to match the the body output. Only a single expression needs to match. HTTP response bodies of up to 100MiB are supported. Example configuration: This monitor examines the -response body for the strings `saved` or `Saved` +response body for the strings `saved` or `Saved` and expects 200 or 201 status codes [source,yaml] ------------------------------------------------------------------------------- @@ -546,7 +546,7 @@ response body for the strings `saved` or `Saved` # urlencode the body: body: "name=first&email=someemail%40someemailprovider.com" check.response: - status: 200 + status: [200, 201] body: - Saved - saved @@ -568,7 +568,7 @@ contains JSON: headers: 'X-API-Key': '12345-mykey-67890' check.response: - status: 200 + status: [200] json: - description: check status condition: @@ -589,7 +589,7 @@ patterns: headers: 'X-API-Key': '12345-mykey-67890' check.response: - status: 200 + status: [200] body: - hello - world @@ -608,7 +608,7 @@ regex: headers: 'X-API-Key': '12345-mykey-67890' check.response: - status: 200 + status: [200] body: '(?s)first.*second.*third' ------------------------------------------------------------------------------- diff --git a/heartbeat/heartbeat.reference.yml b/heartbeat/heartbeat.reference.yml index 8bff01bfe24..8f579e900b8 100644 --- a/heartbeat/heartbeat.reference.yml +++ b/heartbeat/heartbeat.reference.yml @@ -629,9 +629,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # List of root certificates for HTTPS server verifications #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] @@ -721,9 +721,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -894,9 +894,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Certificate for SSL client authentication #ssl.certificate: "/etc/pki/client/cert.pem" @@ -1006,9 +1006,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -1231,7 +1231,7 @@ setup.template.settings: #setup.ilm.pattern: "{now/d}-000001" # Set the lifecycle policy name. The default policy name is -# 'heartbeat-%{[agent.version]}'. +# 'heartbeat'. #setup.ilm.policy_name: "mypolicy" # The path to a JSON file that contains a lifecycle policy configuration. Used @@ -1275,9 +1275,9 @@ setup.kibana: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -1451,9 +1451,9 @@ logging.files: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -1481,6 +1481,14 @@ logging.files: #metrics.period: 10s #state.period: 1m +# The `monitoring.cloud.id` setting overwrites the `monitoring.elasticsearch.hosts` +# setting. You can find the value for this setting in the Elastic Cloud web UI. +#monitoring.cloud.id: + +# The `monitoring.cloud.auth` setting overwrites the `monitoring.elasticsearch.username` +# and `monitoring.elasticsearch.password` settings. The format is `:`. +#monitoring.cloud.auth: + #================================ HTTP Endpoint ====================================== # Each beat can expose internal metrics through a HTTP endpoint. For security # reasons the endpoint is disabled by default. This feature is currently experimental. diff --git a/heartbeat/monitors/active/http/check.go b/heartbeat/monitors/active/http/check.go index 8976cd56304..4ff5ab4a470 100644 --- a/heartbeat/monitors/active/http/check.go +++ b/heartbeat/monitors/active/http/check.go @@ -77,7 +77,7 @@ func makeValidateResponse(config *responseParameters) (multiValidator, error) { var respValidators []respValidator var bodyValidators []bodyValidator - if config.Status > 0 { + if len(config.Status) > 0 { respValidators = append(respValidators, checkStatus(config.Status)) } else { respValidators = append(respValidators, checkStatusOK) @@ -102,10 +102,12 @@ func makeValidateResponse(config *responseParameters) (multiValidator, error) { return multiValidator{respValidators, bodyValidators}, nil } -func checkStatus(status uint16) respValidator { +func checkStatus(status []uint16) respValidator { return func(r *http.Response) error { - if r.StatusCode == int(status) { - return nil + for _, v := range status { + if r.StatusCode == int(v) { + return nil + } } return fmt.Errorf("received status code %v expecting %v", r.StatusCode, status) } diff --git a/heartbeat/monitors/active/http/check_test.go b/heartbeat/monitors/active/http/check_test.go index a705ca34454..3c3e42caa06 100644 --- a/heartbeat/monitors/active/http/check_test.go +++ b/heartbeat/monitors/active/http/check_test.go @@ -268,3 +268,62 @@ func TestCheckJsonWithIntegerComparison(t *testing.T) { } } + +func TestCheckStatus(t *testing.T) { + + var matchTests = []struct { + description string + status []uint16 + statusRec int + result bool + }{ + { + "not match multiple values", + []uint16{200, 301, 302}, + 500, + false, + }, + { + "match multiple values", + []uint16{200, 301, 302}, + 200, + true, + }, + { + "not match single value", + []uint16{200}, + 201, + false, + }, + { + "match single value", + []uint16{200}, + 200, + true, + }, + } + + for _, test := range matchTests { + t.Run(test.description, func(t *testing.T) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(test.statusRec) + })) + defer ts.Close() + + res, err := http.Get(ts.URL) + if err != nil { + log.Fatal(err) + } + + check := checkStatus(test.status)(res) + + if result := (check == nil); result != test.result { + if test.result { + t.Fatalf("Expected at least one of status: %d to match status: %d", test.status, test.statusRec) + } else { + t.Fatalf("Did not expect status: %d to match status: %d", test.status, test.statusRec) + } + } + }) + } +} diff --git a/heartbeat/monitors/active/http/config.go b/heartbeat/monitors/active/http/config.go index 033d8fab628..e195f4209e3 100644 --- a/heartbeat/monitors/active/http/config.go +++ b/heartbeat/monitors/active/http/config.go @@ -74,7 +74,7 @@ type requestParameters struct { type responseParameters struct { // expected HTTP response configuration - Status uint16 `config:"status" verify:"min=0, max=699"` + Status []uint16 `config:"status"` RecvHeaders map[string]string `config:"headers"` RecvBody []match.Matcher `config:"body"` RecvJSON []*jsonResponseCheck `config:"json"` @@ -105,7 +105,6 @@ var defaultConfig = Config{ SendBody: "", }, Response: responseParameters{ - Status: 0, RecvHeaders: nil, RecvBody: []match.Matcher{}, RecvJSON: nil, diff --git a/heartbeat/monitors/active/http/respbody.go b/heartbeat/monitors/active/http/respbody.go index 7990b6324e7..b8b95e5b023 100644 --- a/heartbeat/monitors/active/http/respbody.go +++ b/heartbeat/monitors/active/http/respbody.go @@ -22,7 +22,9 @@ import ( "encoding/hex" "io" "net/http" - "unicode/utf8" + "strings" + + "github.com/docker/go-units" "github.com/elastic/beats/heartbeat/reason" "github.com/elastic/beats/libbeat/common" @@ -31,7 +33,7 @@ import ( // maxBufferBodyBytes sets a hard limit on how much we're willing to buffer for any reason internally. // since we must buffer the whole body for body validators this is effectively a cap on that. // 100MiB out to be enough for everybody. -const maxBufferBodyBytes = 100 * 1024 * 1024 +const maxBufferBodyBytes = 100 * units.MiB func processBody(resp *http.Response, config responseConfig, validator multiValidator) (common.MapStr, reason.Reason) { // Determine how much of the body to actually buffer in memory @@ -94,43 +96,20 @@ func readBody(resp *http.Response, maxSampleBytes int) (bodySample string, bodyS func readPrefixAndHash(body io.ReadCloser, maxPrefixSize int) (respSize int, prefix string, hashStr string, err error) { hash := sha256.New() - // Function to lazily get the body of the response - rawBuf := make([]byte, 1024) - - // Buffer to hold the prefix output along with tracking info - prefixBuf := make([]byte, maxPrefixSize) - prefixRemainingBytes := maxPrefixSize - prefixWriteOffset := 0 - for { - readSize, readErr := body.Read(rawBuf) - - respSize += readSize - hash.Write(rawBuf[:readSize]) - - if prefixRemainingBytes > 0 { - if readSize >= prefixRemainingBytes { - copy(prefixBuf[prefixWriteOffset:maxPrefixSize], rawBuf[:prefixRemainingBytes]) - prefixWriteOffset += prefixRemainingBytes - prefixRemainingBytes = 0 - } else { - copy(prefixBuf[prefixWriteOffset:prefixWriteOffset+readSize], rawBuf[:readSize]) - prefixWriteOffset += readSize - prefixRemainingBytes -= readSize - } - } - if readErr == io.EOF { - break - } + var prefixBuf strings.Builder - if readErr != nil { - return 0, "", "", readErr - } + n, err := io.Copy(&prefixBuf, io.TeeReader(io.LimitReader(body, int64(maxPrefixSize)), hash)) + if err == nil { + // finish streaming into hash if the body has not been fully consumed yet + var m int64 + m, err = io.Copy(hash, body) + n += m } - // We discard the body if it is not valid UTF-8 - if utf8.Valid(prefixBuf[:prefixWriteOffset]) { - prefix = string(prefixBuf[:prefixWriteOffset]) + if err != nil && err != io.EOF { + return 0, "", "", err } - return respSize, prefix, hex.EncodeToString(hash.Sum(nil)), nil + + return int(n), prefixBuf.String(), hex.EncodeToString(hash.Sum(nil)), nil } diff --git a/journalbeat/journalbeat.reference.yml b/journalbeat/journalbeat.reference.yml index 424a38c419b..797b670c690 100644 --- a/journalbeat/journalbeat.reference.yml +++ b/journalbeat/journalbeat.reference.yml @@ -423,9 +423,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # List of root certificates for HTTPS server verifications #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] @@ -515,9 +515,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -688,9 +688,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Certificate for SSL client authentication #ssl.certificate: "/etc/pki/client/cert.pem" @@ -800,9 +800,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -1025,7 +1025,7 @@ setup.template.settings: #setup.ilm.pattern: "{now/d}-000001" # Set the lifecycle policy name. The default policy name is -# 'journalbeat-%{[agent.version]}'. +# 'journalbeat'. #setup.ilm.policy_name: "mypolicy" # The path to a JSON file that contains a lifecycle policy configuration. Used @@ -1069,9 +1069,9 @@ setup.kibana: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -1245,9 +1245,9 @@ logging.files: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -1275,6 +1275,14 @@ logging.files: #metrics.period: 10s #state.period: 1m +# The `monitoring.cloud.id` setting overwrites the `monitoring.elasticsearch.hosts` +# setting. You can find the value for this setting in the Elastic Cloud web UI. +#monitoring.cloud.id: + +# The `monitoring.cloud.auth` setting overwrites the `monitoring.elasticsearch.username` +# and `monitoring.elasticsearch.password` settings. The format is `:`. +#monitoring.cloud.auth: + #================================ HTTP Endpoint ====================================== # Each beat can expose internal metrics through a HTTP endpoint. For security # reasons the endpoint is disabled by default. This feature is currently experimental. diff --git a/libbeat/_meta/config.reference.yml.tmpl b/libbeat/_meta/config.reference.yml.tmpl index 685adc5dd65..79a093f3bd5 100644 --- a/libbeat/_meta/config.reference.yml.tmpl +++ b/libbeat/_meta/config.reference.yml.tmpl @@ -366,9 +366,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # List of root certificates for HTTPS server verifications #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] @@ -458,9 +458,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -631,9 +631,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Certificate for SSL client authentication #ssl.certificate: "/etc/pki/client/cert.pem" @@ -743,9 +743,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -968,7 +968,7 @@ setup.template.settings: #setup.ilm.pattern: "{now/d}-000001" # Set the lifecycle policy name. The default policy name is -# 'beatname-%{[agent.version]}'. +# 'beatname'. #setup.ilm.policy_name: "mypolicy" # The path to a JSON file that contains a lifecycle policy configuration. Used @@ -1012,9 +1012,9 @@ setup.kibana: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -1188,9 +1188,9 @@ logging.files: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -1218,6 +1218,14 @@ logging.files: #metrics.period: 10s #state.period: 1m +# The `monitoring.cloud.id` setting overwrites the `monitoring.elasticsearch.hosts` +# setting. You can find the value for this setting in the Elastic Cloud web UI. +#monitoring.cloud.id: + +# The `monitoring.cloud.auth` setting overwrites the `monitoring.elasticsearch.username` +# and `monitoring.elasticsearch.password` settings. The format is `:`. +#monitoring.cloud.auth: + #================================ HTTP Endpoint ====================================== # Each beat can expose internal metrics through a HTTP endpoint. For security # reasons the endpoint is disabled by default. This feature is currently experimental. diff --git a/libbeat/cmd/instance/imports_common.go b/libbeat/cmd/instance/imports_common.go index 6b78ffc7d56..d8fa4b9f0cf 100644 --- a/libbeat/cmd/instance/imports_common.go +++ b/libbeat/cmd/instance/imports_common.go @@ -24,6 +24,7 @@ import ( _ "github.com/elastic/beats/libbeat/processors/actions" // Register default processors. _ "github.com/elastic/beats/libbeat/processors/add_cloud_metadata" _ "github.com/elastic/beats/libbeat/processors/add_host_metadata" + _ "github.com/elastic/beats/libbeat/processors/add_id" _ "github.com/elastic/beats/libbeat/processors/add_locale" _ "github.com/elastic/beats/libbeat/processors/add_observer_metadata" _ "github.com/elastic/beats/libbeat/processors/add_process_metadata" @@ -32,6 +33,7 @@ import ( _ "github.com/elastic/beats/libbeat/processors/dissect" _ "github.com/elastic/beats/libbeat/processors/dns" _ "github.com/elastic/beats/libbeat/processors/extract_array" + _ "github.com/elastic/beats/libbeat/processors/fingerprint" _ "github.com/elastic/beats/libbeat/processors/registered_domain" _ "github.com/elastic/beats/libbeat/publisher/includes" // Register publisher pipeline modules ) diff --git a/libbeat/common/config.go b/libbeat/common/config.go index 7277d364f06..2f779d996bb 100644 --- a/libbeat/common/config.go +++ b/libbeat/common/config.go @@ -66,18 +66,6 @@ const ( selectorConfigWithPassword = "config-with-passwords" ) -var debugBlacklist = MakeStringSet( - "password", - "passphrase", - "key_passphrase", - "pass", - "proxy_url", - "url", - "urls", - "host", - "hosts", -) - // make hasSelector and configDebugf available for unit testing var hasSelector = logp.HasSelector var configDebugf = logp.Debug @@ -369,7 +357,7 @@ func DebugString(c *Config, filterPrivate bool) string { return fmt.Sprintf(" %v", err) } if filterPrivate { - filterDebugObject(content) + applyLoggingMask(content) } j, _ := json.MarshalIndent(content, "", " ") bufs = append(bufs, string(j)) @@ -380,7 +368,7 @@ func DebugString(c *Config, filterPrivate bool) string { return fmt.Sprintf(" %v", err) } if filterPrivate { - filterDebugObject(content) + applyLoggingMask(content) } j, _ := json.MarshalIndent(content, "", " ") bufs = append(bufs, string(j)) @@ -392,30 +380,6 @@ func DebugString(c *Config, filterPrivate bool) string { return strings.Join(bufs, "\n") } -func filterDebugObject(c interface{}) { - switch cfg := c.(type) { - case map[string]interface{}: - for k, v := range cfg { - if debugBlacklist.Has(k) { - if arr, ok := v.([]interface{}); ok { - for i := range arr { - arr[i] = "xxxxx" - } - } else { - cfg[k] = "xxxxx" - } - } else { - filterDebugObject(v) - } - } - - case []interface{}: - for _, elem := range cfg { - filterDebugObject(elem) - } - } -} - // OwnerHasExclusiveWritePerms asserts that the current user or root is the // owner of the config file and that the config file is (at most) writable by // the owner or root (e.g. group and other cannot have write access). diff --git a/libbeat/common/logging.go b/libbeat/common/logging.go new file mode 100644 index 00000000000..2c5f656abd4 --- /dev/null +++ b/libbeat/common/logging.go @@ -0,0 +1,54 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package common + +var maskList = MakeStringSet( + "password", + "passphrase", + "key_passphrase", + "pass", + "proxy_url", + "url", + "urls", + "host", + "hosts", +) + +func applyLoggingMask(c interface{}) { + switch cfg := c.(type) { + case map[string]interface{}: + for k, v := range cfg { + if maskList.Has(k) { + if arr, ok := v.([]interface{}); ok { + for i := range arr { + arr[i] = "xxxxx" + } + } else { + cfg[k] = "xxxxx" + } + } else { + applyLoggingMask(v) + } + } + + case []interface{}: + for _, elem := range cfg { + applyLoggingMask(elem) + } + } +} diff --git a/libbeat/common/mapstr.go b/libbeat/common/mapstr.go index ca2a31d50b3..8cf589b0f04 100644 --- a/libbeat/common/mapstr.go +++ b/libbeat/common/mapstr.go @@ -20,6 +20,7 @@ package common import ( "encoding/json" "fmt" + "io" "sort" "strings" @@ -218,13 +219,16 @@ func (m MapStr) MarshalLogObject(enc zapcore.ObjectEncoder) error { return nil } - keys := make([]string, 0, len(m)) - for k := range m { + debugM := m.Clone() + applyLoggingMask(map[string]interface{}(debugM)) + + keys := make([]string, 0, len(debugM)) + for k := range debugM { keys = append(keys, k) } sort.Strings(keys) for _, k := range keys { - v := m[k] + v := debugM[k] if inner, ok := tryToMapStr(v); ok { enc.AddObject(k, inner) continue @@ -234,6 +238,19 @@ func (m MapStr) MarshalLogObject(enc zapcore.ObjectEncoder) error { return nil } +// Format implements fmt.Formatter +func (m MapStr) Format(f fmt.State, c rune) { + if f.Flag('+') || f.Flag('#') { + io.WriteString(f, m.String()) + return + } + + debugM := m.Clone() + applyLoggingMask(map[string]interface{}(debugM)) + + io.WriteString(f, debugM.String()) +} + // Flatten flattens the given MapStr and returns a flat MapStr. // // Example: diff --git a/libbeat/common/mapstr_test.go b/libbeat/common/mapstr_test.go index 34223344d80..784814bdac3 100644 --- a/libbeat/common/mapstr_test.go +++ b/libbeat/common/mapstr_test.go @@ -1002,3 +1002,26 @@ func BenchmarkWalkMap(b *testing.B) { } }) } + +func TestFormat(t *testing.T) { + input := MapStr{ + "foo": "bar", + "password": "SUPER_SECURE", + } + + tests := map[string]string{ + "%v": `{"foo":"bar","password":"xxxxx"}`, + "%+v": `{"foo":"bar","password":"SUPER_SECURE"}`, + "%#v": `{"foo":"bar","password":"SUPER_SECURE"}`, + "%s": `{"foo":"bar","password":"xxxxx"}`, + "%+s": `{"foo":"bar","password":"SUPER_SECURE"}`, + "%#s": `{"foo":"bar","password":"SUPER_SECURE"}`, + } + + for verb, expected := range tests { + t.Run(verb, func(t *testing.T) { + actual := fmt.Sprintf(verb, input) + assert.Equal(t, expected, actual) + }) + } +} diff --git a/libbeat/docs/release-notes/breaking/breaking-7.6.asciidoc b/libbeat/docs/release-notes/breaking/breaking-7.6.asciidoc new file mode 100644 index 00000000000..7d72610fbd7 --- /dev/null +++ b/libbeat/docs/release-notes/breaking/breaking-7.6.asciidoc @@ -0,0 +1,15 @@ +[[breaking-changes-7.6]] + +=== Breaking changes in 7.6 +++++ +7.6 +++++ + +{see-relnotes} + +//NOTE: The notable-breaking-changes tagged regions are re-used in the +//Installation and Upgrade Guide + +//tag::notable-breaking-changes[] + +// end::notable-breaking-changes[] diff --git a/libbeat/docs/release-notes/breaking/breaking.asciidoc b/libbeat/docs/release-notes/breaking/breaking.asciidoc index d3f4aa40d07..cb6aec8d0ce 100644 --- a/libbeat/docs/release-notes/breaking/breaking.asciidoc +++ b/libbeat/docs/release-notes/breaking/breaking.asciidoc @@ -11,6 +11,8 @@ changes, but there are breaking changes between major versions (e.g. 6.x to See the following topics for a description of breaking changes: +* <> + * <> * <> @@ -23,6 +25,8 @@ See the following topics for a description of breaking changes: * <> +include::breaking-7.6.asciidoc[] + include::breaking-7.5.asciidoc[] include::breaking-7.4.asciidoc[] diff --git a/libbeat/docs/release-notes/highlights/highlights-7.6.0.asciidoc b/libbeat/docs/release-notes/highlights/highlights-7.6.0.asciidoc new file mode 100644 index 00000000000..2890861b3f2 --- /dev/null +++ b/libbeat/docs/release-notes/highlights/highlights-7.6.0.asciidoc @@ -0,0 +1,26 @@ +[[release-highlights-7.6.0]] +=== 7.6 release highlights +++++ +7.6 +++++ + +Each release of {beats} brings new features and product improvements. +Following are the most notable features and enhancements in 7.6. + +For a complete list of highlights, see the +https://www.elastic.co/blog/beats-7-6-0-released[{beats} 7.6 release blog]. + +For a list of bug fixes and other changes, see the {beats} +<> and <>. + +//NOTE: The notable-highlights tagged regions are re-used in the +//Installation and Upgrade Guide + +// tag::notable-highlights[] + +//[float] +//==== Highlight + +//Description + +// end::notable-highlights[] diff --git a/libbeat/docs/release-notes/highlights/highlights.asciidoc b/libbeat/docs/release-notes/highlights/highlights.asciidoc index b77111f062f..37b95396fc7 100644 --- a/libbeat/docs/release-notes/highlights/highlights.asciidoc +++ b/libbeat/docs/release-notes/highlights/highlights.asciidoc @@ -4,6 +4,8 @@ This section summarizes the most important changes in each release. For the full list, see <> and <>. +* <> + * <> * <> @@ -16,6 +18,8 @@ full list, see <> and <>. * <> +include::highlights-7.6.0.asciidoc[] + include::highlights-7.5.0.asciidoc[] include::highlights-7.4.0.asciidoc[] diff --git a/libbeat/docs/security/users.asciidoc b/libbeat/docs/security/users.asciidoc index d8dff16a15f..f69ac1658a6 100644 --- a/libbeat/docs/security/users.asciidoc +++ b/libbeat/docs/security/users.asciidoc @@ -214,8 +214,9 @@ endif::serverless[] ==== Grant privileges and roles needed for publishing Users who publish events to {es} need to create and write to {beatname_uc} -indices. To minimize the privileges required by the writer role, you can use the -<> to pre-load dependencies. +indices. To minimize the privileges required by the writer role, use the +<> to pre-load dependencies. This section +assumes that you've pre-loaded dependencies. ifndef::no_ilm[] When using ILM, turn off the ILM setup check in the {beatname_uc} config file before diff --git a/libbeat/docs/shared-ilm.asciidoc b/libbeat/docs/shared-ilm.asciidoc index 12069381c2c..4ed4cba0e2a 100644 --- a/libbeat/docs/shared-ilm.asciidoc +++ b/libbeat/docs/shared-ilm.asciidoc @@ -66,7 +66,7 @@ Date math is supported in this setting. For example: [source,yaml] ---- -setup.ilm.pattern: "{now/M{YYYY.MM}}-000001" +setup.ilm.pattern: "{now/M{yyyy.MM}}-000001" ---- For more information, see @@ -81,7 +81,7 @@ overwrite the template to apply the changes. ==== `setup.ilm.policy_name` The name to use for the lifecycle policy. The default is -+{beatname_lc}-%{[{beat_version_key}]}+. ++{beatname_lc}+. [float] [[setup-ilm-policy_file-option]] diff --git a/libbeat/outputs/logstash/async.go b/libbeat/outputs/logstash/async.go index 96374e192d0..967ae7d0f6c 100644 --- a/libbeat/outputs/logstash/async.go +++ b/libbeat/outputs/logstash/async.go @@ -18,7 +18,9 @@ package logstash import ( + "errors" "net" + "sync" "time" "github.com/elastic/beats/libbeat/beat" @@ -37,6 +39,8 @@ type asyncClient struct { win *window connect func() error + + mutex sync.Mutex } type msgRef struct { @@ -113,7 +117,11 @@ func (c *asyncClient) Connect() error { } func (c *asyncClient) Close() error { + c.mutex.Lock() + defer c.mutex.Unlock() + logp.Debug("logstash", "close connection") + if c.client != nil { err := c.client.Close() c.client = nil @@ -197,12 +205,23 @@ func (c *asyncClient) publishWindowed( } func (c *asyncClient) sendEvents(ref *msgRef, events []publisher.Event) error { + client := c.getClient() + if client == nil { + return errors.New("connection closed") + } window := make([]interface{}, len(events)) for i := range events { window[i] = &events[i].Content } ref.count.Inc() - return c.client.Send(ref.callback, window) + return client.Send(ref.callback, window) +} + +func (c *asyncClient) getClient() *v2.AsyncClient { + c.mutex.Lock() + client := c.client + c.mutex.Unlock() + return client } func (r *msgRef) callback(seq uint32, err error) { diff --git a/metricbeat/autodiscover/builder/hints/metrics.go b/metricbeat/autodiscover/builder/hints/metrics.go index c10b39967c4..247d3046860 100644 --- a/metricbeat/autodiscover/builder/hints/metrics.go +++ b/metricbeat/autodiscover/builder/hints/metrics.go @@ -141,14 +141,14 @@ func (m *metricHints) CreateConfig(event bus.Event) []*common.Config { moduleConfig["password"] = password } - logp.Debug("hints.builder", "generated config: %v", moduleConfig.String()) + logp.Debug("hints.builder", "generated config: %v", moduleConfig) // Create config object cfg, err := common.NewConfigFrom(moduleConfig) if err != nil { logp.Debug("hints.builder", "config merge failed with error: %v", err) } - logp.Debug("hints.builder", "generated config: +%v", *cfg) + logp.Debug("hints.builder", "generated config: %+v", common.DebugString(cfg, true)) config = append(config, cfg) // Apply information in event to the template to generate the final config diff --git a/metricbeat/docs/fields.asciidoc b/metricbeat/docs/fields.asciidoc index 7d2b1f7f642..472d6794091 100644 --- a/metricbeat/docs/fields.asciidoc +++ b/metricbeat/docs/fields.asciidoc @@ -42,6 +42,7 @@ grouped in the following categories: * <> * <> * <> +* <> * <> * <> * <> @@ -1558,1075 +1559,594 @@ type: object *`aws.*.metrics.*.*`*:: + -- -Metrics that returned from Cloudwatch API query. - name: billing - type: group - description: > - `billing` contains the estimated charges for your AWS account in Cloudwatch. - release: beta - fields: -- name: cloudwatch - type: group - description: > - `cloudwatch` contains the metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by different namespaces. - release: ga - fields: - - name: namespace - type: keyword - description: > - The namespace specified when query cloudwatch api. -- name: dynamodb - type: group - description: > - `dynamodb` contains the metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by AWS DynamoDB. - release: beta - fields: -- name: ebs - type: group - description: > - `ebs` contains the metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by AWS EBS. - release: ga - fields: -- name: ec2 - type: group - description: > - `ec2` contains the metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by AWS EC2. - release: ga - fields: - - name: cpu.total.pct - type: scaled_float - description: > - The percentage of allocated EC2 compute units that are currently in use on the instance. - - name: cpu.credit_usage - type: long - description: > - The number of CPU credits spent by the instance for CPU utilization. - - name: cpu.credit_balance - type: long - description: > - The number of earned CPU credits that an instance has accrued since it was launched or started. - - name: cpu.surplus_credit_balance - type: long - description: > - The number of surplus credits that have been spent by an unlimited instance when its CPUCreditBalance value is zero. - - name: cpu.surplus_credits_charged - type: long - description: > - The number of spent surplus credits that are not paid down by earned CPU credits, and which thus incur an additional charge. - - name: network.in.packets - type: long - description: > - The number of packets received on all network interfaces by the instance. - - name: network.in.packets_per_sec - type: long - description: > - The number of packets per second sent out on all network interfaces by the instance. - - name: network.out.packets - type: long - description: > - The number of packets sent out on all network interfaces by the instance. - - name: network.out.packets_per_sec - type: long - description: > - The number of packets per second sent out on all network interfaces by the instance. - - name: network.in.bytes - type: long - format: bytes - description: > - The number of bytes received on all network interfaces by the instance. - - name: network.in.bytes_per_sec - type: long - description: > - The number of bytes per second received on all network interfaces by the instance. - - name: network.out.bytes - type: long - format: bytes - description: > - The number of bytes sent out on all network interfaces by the instance. - - name: network.out.bytes_per_sec - type: long - description: > - The number of bytes per second sent out on all network interfaces by the instance. - - name: diskio.read.bytes - type: long - format: bytes - description: > - Bytes read from all instance store volumes available to the instance. - - name: diskio.read.bytes_per_sec - type: long - description: > - Bytes read per second from all instance store volumes available to the instance. - - name: diskio.write.bytes - type: long - format: bytes - description: > - Bytes written to all instance store volumes available to the instance. - - name: diskio.write.bytes_per_sec - type: long - description: > - Bytes written per second to all instance store volumes available to the instance. - - name: diskio.read.ops - type: long - description: > - Completed read operations from all instance store volumes available to the instance in a specified period of time. - - name: diskio.read.ops_per_sec - type: long - description: > - Completed read operations per second from all instance store volumes available to the instance in a specified period of time. - - name: diskio.write.ops - type: long - description: > - Completed write operations to all instance store volumes available to the instance in a specified period of time. - - name: diskio.write.ops_per_sec - type: long - description: > - Completed write operations per second to all instance store volumes available to the instance in a specified period of time. - - name: status.check_failed - type: long - description: > - Reports whether the instance has passed both the instance status check and the system status check in the last minute. - - name: status.check_failed_system - type: long - description: > - Reports whether the instance has passed the system status check in the last minute. - - name: status.check_failed_instance - type: long - description: > - Reports whether the instance has passed the instance status check in the last minute. - - name: instance.core.count - type: integer - description: > - The number of CPU cores for the instance. - - name: instance.image.id - type: keyword - description: > - The ID of the image used to launch the instance. - - name: instance.monitoring.state - type: keyword - description: > - Indicates whether detailed monitoring is enabled. - - name: instance.private.dns_name - type: keyword - description: > - The private DNS name of the network interface. - - name: instance.private.ip - type: ip - description: > - The private IPv4 address associated with the network interface. - - name: instance.public.dns_name - type: keyword - description: > - The public DNS name of the instance. - - name: instance.public.ip - type: ip - description: > - The address of the Elastic IP address (IPv4) bound to the network interface. - - name: instance.state.code - type: integer - description: > - The state of the instance, as a 16-bit unsigned integer. - - name: instance.state.name - type: keyword - description: > - The state of the instance (pending | running | shutting-down | terminated | stopping | stopped). - - name: instance.threads_per_core - type: integer - description: > - The number of threads per CPU core. -- name: elb - type: group - description: > - `elb` contains the metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by AWS ELB. - release: ga - fields: -- name: lambda - type: group - description: > - `lambda` contains the metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by AWS Lambda. - release: beta - fields: -- name: rds - type: group - description: > - `rds` contains the metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by AWS RDS. - release: ga - fields: - - name: cpu.total.pct - type: scaled_float - format: percent - description: > - The percentage of CPU utilization. - - name: cpu.credit_usage - type: long - description: > - The number of CPU credits spent by the instance for CPU utilization. - - name: cpu.credit_balance - type: long - description: > - The number of earned CPU credits that an instance has accrued since it was launched or started. - - name: database_connections - type: long - description: > - The number of database connections in use. - - name: db_instance.arn - type: keyword - description: > - Amazon Resource Name(ARN) for each rds. - - name: db_instance.class - type: keyword - description: > - Contains the name of the compute and memory capacity class of the DB instance. - - name: db_instance.identifier - type: keyword - description: > - Contains a user-supplied database identifier. This identifier is the unique key that identifies a DB instance. - - name: db_instance.status - type: keyword - description: > - Specifies the current state of this database. - - name: disk_queue_depth - type: float - description: > - The number of outstanding IOs (read/write requests) waiting to access the disk. - - name: failed_sql_server_agent_jobs - type: long - description: > - The number of failed SQL Server Agent jobs during the last minute. - - name: freeable_memory.bytes - type: long - format: bytes - description: > - The amount of available random access memory. - - name: free_storage.bytes - type: long - format: bytes - description: > - The amount of available storage space. - - name: maximum_used_transaction_ids - type: long - description: > - The maximum transaction ID that has been used. Applies to PostgreSQL. - - name: oldest_replication_slot_lag.mb - type: long - description: > - The lagging size of the replica lagging the most in terms of WAL data received. Applies to PostgreSQL. - - name: read_io.ops_per_sec - type: float - description: > - The average number of disk read I/O operations per second. - - name: replica_lag.sec - type: long - format: duration - description: > - The amount of time a Read Replica DB instance lags behind the source DB instance. Applies to MySQL, MariaDB, and PostgreSQL Read Replicas. - - name: swap_usage.bytes - type: long - format: bytes - description: > - The amount of swap space used on the DB instance. This metric is not available for SQL Server. - - name: transaction_logs_generation - type: long - description: > - The disk space used by transaction logs. Applies to PostgreSQL. - - name: write_io.ops_per_sec - type: float - description: > - The average number of disk write I/O operations per second. - - name: queries - type: long - description: > - The average number of queries executed per second. - - name: deadlocks - type: long - description: > - The average number of deadlocks in the database per second. - - name: volume_used.bytes - type: long - format: bytes - description: > - The amount of storage used by your Aurora DB instance, in bytes. - - name: free_local_storage.bytes - type: long - format: bytes - description: > - The amount of storage available for temporary tables and logs, in bytes. - - name: login_failures - type: long - description: > - The average number of failed login attempts per second. - - name: throughput.commit - type: float - description: > - The average number of commit operations per second. - - name: throughput.delete - type: float - description: > - The average number of delete queries per second. - - name: throughput.ddl - type: float - description: > - The average number of DDL requests per second. - - name: throughput.dml - type: float - description: > - The average number of inserts, updates, and deletes per second. - - name: throughput.insert - type: float - description: > - The average number of insert queries per second. - - name: throughput.network - type: float - description: > - The amount of network throughput both received from and transmitted to clients by each instance in the Aurora MySQL DB cluster, in bytes per second. - - name: throughput.network_receive - type: float - description: > - The incoming (Receive) network traffic on the DB instance, including both customer database traffic and Amazon RDS traffic used for monitoring and replication. - - name: throughput.network_transmit - type: float - description: > - The outgoing (Transmit) network traffic on the DB instance, including both customer database traffic and Amazon RDS traffic used for monitoring and replication. - - name: throughput.read - type: float - description: > - The average amount of time taken per disk I/O operation. - - name: throughput.select - type: float - description: > - The average number of select queries per second. - - name: throughput.update - type: float - description: > - The average number of update queries per second. - - name: throughput.write - type: float - description: > - The average number of bytes written to disk per second. - - name: latency.commit - type: float - format: duration - description: > - The amount of latency for commit operations, in milliseconds. - - name: latency.ddl - type: float - format: duration - description: > - The amount of latency for data definition language (DDL) requests, in milliseconds. - - name: latency.dml - type: float - format: duration - description: > - The amount of latency for inserts, updates, and deletes, in milliseconds. - - name: latency.insert - type: float - format: duration - description: > - The amount of latency for insert queries, in milliseconds. - - name: latency.read - type: float - format: duration - description: > - The average amount of time taken per disk I/O operation. - - name: latency.select - type: float - format: duration - description: > - The amount of latency for select queries, in milliseconds. - - name: latency.update - type: float - format: duration - description: > - The amount of latency for update queries, in milliseconds. - - name: latency.write - type: float - format: duration - description: > - The average amount of time taken per disk I/O operation. - - name: disk_usage.bin_log.bytes - type: long - format: bytes - description: > - The amount of disk space occupied by binary logs on the master. Applies to MySQL read replicas. - - name: disk_usage.replication_slot.mb - type: long - description: > - The disk space used by replication slot files. Applies to PostgreSQL. - - name: disk_usage.transaction_logs.mb - type: long - description: > - The disk space used by transaction logs. Applies to PostgreSQL. - - name: transactions.active - type: long - description: > - The average number of current transactions executing on an Aurora database instance per second. - - name: transactions.blocked - type: long - description: > - The average number of transactions in the database that are blocked per second. - - name: db_instance.db_cluster_identifier - type: keyword - description: > - This identifier is the unique key that identifies a DB cluster specifically for Amazon Aurora DB cluster. - - name: db_instance.role - type: keyword - description: > - DB roles like WRITER or READER, specifically for Amazon Aurora DB cluster. - - name: db_instance.engine_name - type: keyword - description: > - Each DB instance runs a DB engine, like MySQL, MariaDB, PostgreSQL and etc. -- name: s3_daily_storage - type: group - description: > - `s3_daily_storage` contains the daily storage metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by AWS S3. - release: ga - fields: - - name: bucket.size.bytes - type: long - format: bytes - description: > - The amount of data in bytes stored in a bucket. - - name: number_of_objects - type: long - description: > - The total number of objects stored in a bucket for all storage classes. -- name: s3_request - type: group - description: > - `s3_request` contains request metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by AWS S3. - release: ga - fields: - - name: requests.total - type: long - description: > - The total number of HTTP requests made to an Amazon S3 bucket, regardless of type. - - name: requests.get - type: long - description: > - The number of HTTP GET requests made for objects in an Amazon S3 bucket. - - name: requests.put - type: long - description: > - The number of HTTP PUT requests made for objects in an Amazon S3 bucket. - - name: requests.delete - type: long - description: > - The number of HTTP DELETE requests made for objects in an Amazon S3 bucket. - - name: requests.head - type: long - description: > - The number of HTTP HEAD requests made to an Amazon S3 bucket. - - name: requests.post - type: long - description: > - The number of HTTP POST requests made to an Amazon S3 bucket. - - name: requests.select - type: long - description: > - The number of Amazon S3 SELECT Object Content requests made for objects in an Amazon S3 bucket. - - name: requests.select_scanned.bytes - type: long - format: bytes - description: > - The number of bytes of data scanned with Amazon S3 SELECT Object Content requests in an Amazon S3 bucket. - - name: requests.select_returned.bytes - type: long - format: bytes - description: > - The number of bytes of data returned with Amazon S3 SELECT Object Content requests in an Amazon S3 bucket. - - name: requests.list - type: long - description: > - The number of HTTP requests that list the contents of a bucket. - - name: downloaded.bytes - type: long - format: bytes - description: > - The number bytes downloaded for requests made to an Amazon S3 bucket, where the response includes a body. - - name: uploaded.bytes - type: long - format: bytes - description: > - The number bytes uploaded that contain a request body, made to an Amazon S3 bucket. - - name: errors.4xx - type: long - description: > - The number of HTTP 4xx client error status code requests made to an Amazon S3 bucket with a value of either 0 or 1. - - name: errors.5xx - type: long - description: > - The number of HTTP 5xx server error status code requests made to an Amazon S3 bucket with a value of either 0 or 1. - - name: latency.first_byte.ms - type: long - format: duration - description: > - The per-request time from the complete request being received by an Amazon S3 bucket to when the response starts to be returned. - - name: latency.total_request.ms - type: long - format: duration - description: > - The elapsed per-request time from the first byte received to the last byte sent to an Amazon S3 bucket. -- name: sns - type: group - description: > - `sns` contains the metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by AWS SNS. - release: beta - fields: -- name: sqs - type: group - description: > - `sqs` contains the metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by AWS SQS. - release: ga - fields: - - name: oldest_message_age.sec - type: long - format: duration - description: > - The approximate age of the oldest non-deleted message in the queue. - - name: messages.delayed - type: long - description: > - TThe number of messages in the queue that are delayed and not available for reading immediately. - - name: messages.not_visible - type: long - description: > - The number of messages that are in flight. - - name: messages.visible - type: long - description: > - The number of messages available for retrieval from the queue. - - name: messages.deleted - type: long - description: > - The number of messages deleted from the queue. - - name: messages.received - type: long - description: > - The number of messages returned by calls to the ReceiveMessage action. - - name: messages.sent - type: long - description: > - The number of messages added to a queue. - - name: empty_receives - type: long - description: > - The number of ReceiveMessage API calls that did not return a message. - - name: sent_message_size.bytes - type: long - format: bytes - description: > - The size of messages added to a queue. - - name: queue.name - type: keyword - description: > - SQS queue name -- name: usage - type: group - description: > - `usage` contains the metrics from Cloudwatch to track usage of some AWS resources. - release: beta - fields: +Metrics that returned from Cloudwatch API query. type: object -- -[[exported-fields-azure]] -== azure fields +[float] +=== billing -azure module +`billing` contains the estimated charges for your AWS account in Cloudwatch. + + +[float] +=== cloudwatch + +`cloudwatch` contains the metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by different namespaces. +*`aws.cloudwatch.namespace`*:: ++ +-- +The namespace specified when query cloudwatch api. + + +type: keyword + +-- + [float] -=== azure +=== dynamodb + +`dynamodb` contains the metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by AWS DynamoDB. +[float] +=== ebs + +`ebs` contains the metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by AWS EBS. [float] -=== resource +=== ec2 -The resource specified +`ec2` contains the metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by AWS EC2. -*`azure.resource.name`*:: +*`aws.ec2.cpu.total.pct`*:: + -- -The name of the resource +The percentage of allocated EC2 compute units that are currently in use on the instance. -type: keyword +type: scaled_float -- -*`azure.resource.type`*:: +*`aws.ec2.cpu.credit_usage`*:: + -- -The type of the resource +The number of CPU credits spent by the instance for CPU utilization. -type: keyword +type: long -- -*`azure.resource.group`*:: +*`aws.ec2.cpu.credit_balance`*:: + -- -The resource group +The number of earned CPU credits that an instance has accrued since it was launched or started. -type: keyword +type: long -- -*`azure.resource.tags.*`*:: +*`aws.ec2.cpu.surplus_credit_balance`*:: + -- -Azure resource tags. +The number of surplus credits that have been spent by an unlimited instance when its CPUCreditBalance value is zero. -type: object +type: long -- -*`azure.namespace`*:: +*`aws.ec2.cpu.surplus_credits_charged`*:: + -- -The namespace selected +The number of spent surplus credits that are not paid down by earned CPU credits, and which thus incur an additional charge. -type: keyword +type: long -- -*`azure.subscription_id`*:: +*`aws.ec2.network.in.packets`*:: + -- -The subscription ID +The number of packets received on all network interfaces by the instance. -type: keyword +type: long -- -*`azure.dimensions.*`*:: +*`aws.ec2.network.in.packets_per_sec`*:: + -- -Azure metric dimensions. +The number of packets per second sent out on all network interfaces by the instance. -type: object +type: long -- -*`azure.compute_vm.*.*`*:: +*`aws.ec2.network.out.packets`*:: + -- -compute_vm +The number of packets sent out on all network interfaces by the instance. -type: object +type: long -- -*`azure.compute_vm_scaleset.*.*`*:: +*`aws.ec2.network.out.packets_per_sec`*:: + -- -compute_vm_scaleset +The number of packets per second sent out on all network interfaces by the instance. -type: object +type: long -- -[float] -=== monitor +*`aws.ec2.network.in.bytes`*:: ++ +-- +The number of bytes received on all network interfaces by the instance. -monitor +type: long + +format: bytes +-- -*`azure.monitor.metrics.*.*`*:: +*`aws.ec2.network.in.bytes_per_sec`*:: + -- -Metrics returned. +The number of bytes per second received on all network interfaces by the instance. -type: object +type: long -- -*`azure.storage.*.*`*:: +*`aws.ec2.network.out.bytes`*:: + -- -storage account +The number of bytes sent out on all network interfaces by the instance. -type: object +type: long + +format: bytes -- -[[exported-fields-beat-common]] -== Beat fields +*`aws.ec2.network.out.bytes_per_sec`*:: ++ +-- +The number of bytes per second sent out on all network interfaces by the instance. -Contains common beat fields available in all event types. +type: long +-- -*`agent.hostname`*:: +*`aws.ec2.diskio.read.bytes`*:: + -- -Hostname of the agent. +Bytes read from all instance store volumes available to the instance. -type: keyword + +type: long + +format: bytes -- -*`beat.timezone`*:: +*`aws.ec2.diskio.read.bytes_per_sec`*:: + -- -type: alias +Bytes read per second from all instance store volumes available to the instance. -alias to: event.timezone + +type: long -- -*`fields`*:: +*`aws.ec2.diskio.write.bytes`*:: + -- -Contains user configurable fields. +Bytes written to all instance store volumes available to the instance. -type: object +type: long + +format: bytes -- -*`beat.name`*:: +*`aws.ec2.diskio.write.bytes_per_sec`*:: + -- -type: alias +Bytes written per second to all instance store volumes available to the instance. -alias to: host.name + +type: long -- -*`beat.hostname`*:: +*`aws.ec2.diskio.read.ops`*:: + -- -type: alias +Completed read operations from all instance store volumes available to the instance in a specified period of time. -alias to: agent.hostname + +type: long -- -*`timeseries.instance`*:: +*`aws.ec2.diskio.read.ops_per_sec`*:: + -- -Time series instance id +Completed read operations per second from all instance store volumes available to the instance in a specified period of time. -type: keyword + +type: long -- -[[exported-fields-beat]] -== Beat fields +*`aws.ec2.diskio.write.ops`*:: ++ +-- +Completed write operations to all instance store volumes available to the instance in a specified period of time. -Beat module +type: long +-- -[float] -=== beat +*`aws.ec2.diskio.write.ops_per_sec`*:: ++ +-- +Completed write operations per second to all instance store volumes available to the instance in a specified period of time. +type: long +-- -*`beat.id`*:: +*`aws.ec2.status.check_failed`*:: + -- -Beat ID. +Reports whether the instance has passed both the instance status check and the system status check in the last minute. -type: keyword +type: long -- -*`beat.type`*:: +*`aws.ec2.status.check_failed_system`*:: + -- -Beat type. +Reports whether the instance has passed the system status check in the last minute. -type: keyword +type: long -- -[float] -=== state +*`aws.ec2.status.check_failed_instance`*:: ++ +-- +Reports whether the instance has passed the instance status check in the last minute. -Beat state +type: long +-- -*`beat.state.management.enabled`*:: +*`aws.ec2.instance.core.count`*:: + -- -Is central management enabled? +The number of CPU cores for the instance. -type: boolean +type: integer -- -*`beat.state.module.count`*:: +*`aws.ec2.instance.image.id`*:: + -- -Number of modules enabled +The ID of the image used to launch the instance. -type: integer +type: keyword -- -*`beat.state.output.name`*:: +*`aws.ec2.instance.monitoring.state`*:: + -- -Name of output used by Beat +Indicates whether detailed monitoring is enabled. type: keyword -- -*`beat.state.queue.name`*:: +*`aws.ec2.instance.private.dns_name`*:: + -- -Name of queue being used by Beat +The private DNS name of the network interface. type: keyword -- -[float] -=== stats +*`aws.ec2.instance.private.ip`*:: ++ +-- +The private IPv4 address associated with the network interface. -Beat stats +type: ip +-- -*`beat.stats.uptime.ms`*:: +*`aws.ec2.instance.public.dns_name`*:: + -- -Beat uptime +The public DNS name of the instance. -type: long +type: keyword -- -*`beat.stats.runtime.goroutines`*:: +*`aws.ec2.instance.public.ip`*:: + -- -Number of goroutines running in Beat +The address of the Elastic IP address (IPv4) bound to the network interface. -type: long +type: ip -- -[float] -=== libbeat +*`aws.ec2.instance.state.code`*:: ++ +-- +The state of the instance, as a 16-bit unsigned integer. -Fields common to all Beats +type: integer +-- -[float] -=== output +*`aws.ec2.instance.state.name`*:: ++ +-- +The state of the instance (pending | running | shutting-down | terminated | stopping | stopped). -Output stats +type: keyword +-- -*`beat.stats.libbeat.output.type`*:: +*`aws.ec2.instance.threads_per_core`*:: + -- -Type of output +The number of threads per CPU core. -type: keyword +type: integer -- [float] -=== events +=== elb -Event counters +`elb` contains the metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by AWS ELB. +[float] +=== lambda -*`beat.stats.libbeat.output.events.acked`*:: +`lambda` contains the metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by AWS Lambda. + + +[float] +=== rds + +`rds` contains the metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by AWS RDS. + + + +*`aws.rds.cpu.total.pct`*:: + -- -Number of events acknowledged +The percentage of CPU utilization. -type: long +type: scaled_float + +format: percent -- -*`beat.stats.libbeat.output.events.active`*:: +*`aws.rds.cpu.credit_usage`*:: + -- -Number of active events +The number of CPU credits spent by the instance for CPU utilization. type: long -- -*`beat.stats.libbeat.output.events.batches`*:: +*`aws.rds.cpu.credit_balance`*:: + -- -Number of event batches +The number of earned CPU credits that an instance has accrued since it was launched or started. type: long -- -*`beat.stats.libbeat.output.events.dropped`*:: +*`aws.rds.database_connections`*:: + -- -Number of events dropped +The number of database connections in use. type: long -- -*`beat.stats.libbeat.output.events.duplicates`*:: +*`aws.rds.db_instance.arn`*:: + -- -Number of events duplicated +Amazon Resource Name(ARN) for each rds. -type: long +type: keyword -- -*`beat.stats.libbeat.output.events.failed`*:: +*`aws.rds.db_instance.class`*:: + -- -Number of events failed +Contains the name of the compute and memory capacity class of the DB instance. -type: long +type: keyword -- -*`beat.stats.libbeat.output.events.toomany`*:: +*`aws.rds.db_instance.identifier`*:: + -- -Number of too many events +Contains a user-supplied database identifier. This identifier is the unique key that identifies a DB instance. -type: long +type: keyword -- -*`beat.stats.libbeat.output.events.total`*:: +*`aws.rds.db_instance.status`*:: + -- -Total number of events +Specifies the current state of this database. -type: long +type: keyword -- -[float] -=== read +*`aws.rds.disk_queue_depth`*:: ++ +-- +The number of outstanding IOs (read/write requests) waiting to access the disk. -Read stats +type: float +-- -*`beat.stats.libbeat.output.read.bytes`*:: +*`aws.rds.failed_sql_server_agent_jobs`*:: + -- -Number of bytes read +The number of failed SQL Server Agent jobs during the last minute. type: long -- -*`beat.stats.libbeat.output.read.errors`*:: +*`aws.rds.freeable_memory.bytes`*:: + -- -Number of read errors +The amount of available random access memory. type: long +format: bytes + -- -[float] -=== write +*`aws.rds.free_storage.bytes`*:: ++ +-- +The amount of available storage space. -Write stats +type: long + +format: bytes +-- -*`beat.stats.libbeat.output.write.bytes`*:: +*`aws.rds.maximum_used_transaction_ids`*:: + -- -Number of bytes written +The maximum transaction ID that has been used. Applies to PostgreSQL. type: long -- -*`beat.stats.libbeat.output.write.errors`*:: +*`aws.rds.oldest_replication_slot_lag.mb`*:: + -- -Number of write errors +The lagging size of the replica lagging the most in terms of WAL data received. Applies to PostgreSQL. type: long -- -[[exported-fields-ceph]] -== Ceph fields - -Ceph module - - +*`aws.rds.read_io.ops_per_sec`*:: ++ +-- +The average number of disk read I/O operations per second. -[float] -=== ceph -`ceph` contains the metrics that were scraped from CEPH. +type: float +-- +*`aws.rds.replica_lag.sec`*:: ++ +-- +The amount of time a Read Replica DB instance lags behind the source DB instance. Applies to MySQL, MariaDB, and PostgreSQL Read Replicas. -[float] -=== cluster_disk -cluster_disk +type: long +format: duration +-- -*`ceph.cluster_disk.available.bytes`*:: +*`aws.rds.swap_usage.bytes`*:: + -- -Available bytes of the cluster +The amount of swap space used on the DB instance. This metric is not available for SQL Server. type: long @@ -2635,455 +2155,488 @@ format: bytes -- -*`ceph.cluster_disk.total.bytes`*:: +*`aws.rds.transaction_logs_generation`*:: + -- -Total bytes of the cluster +The disk space used by transaction logs. Applies to PostgreSQL. type: long -format: bytes +-- +*`aws.rds.write_io.ops_per_sec`*:: ++ -- +The average number of disk write I/O operations per second. -*`ceph.cluster_disk.used.bytes`*:: + +type: float + +-- + +*`aws.rds.queries`*:: + -- -Used bytes of the cluster +The average number of queries executed per second. type: long -format: bytes - -- -[float] -=== cluster_health +*`aws.rds.deadlocks`*:: ++ +-- +The average number of deadlocks in the database per second. -cluster_health +type: long +-- -*`ceph.cluster_health.overall_status`*:: +*`aws.rds.volume_used.bytes`*:: + -- -Overall status of the cluster +The amount of storage used by your Aurora DB instance, in bytes. -type: keyword +type: long + +format: bytes -- -*`ceph.cluster_health.timechecks.epoch`*:: +*`aws.rds.free_local_storage.bytes`*:: + -- -Map version +The amount of storage available for temporary tables and logs, in bytes. type: long +format: bytes + -- -*`ceph.cluster_health.timechecks.round.value`*:: +*`aws.rds.login_failures`*:: + -- -timecheck round +The average number of failed login attempts per second. type: long -- -*`ceph.cluster_health.timechecks.round.status`*:: +*`aws.rds.throughput.commit`*:: + -- -Status of the round +The average number of commit operations per second. -type: keyword +type: float -- -[float] -=== cluster_status +*`aws.rds.throughput.delete`*:: ++ +-- +The average number of delete queries per second. -cluster_status +type: float +-- -*`ceph.cluster_status.version`*:: +*`aws.rds.throughput.ddl`*:: + -- -Ceph Status version +The average number of DDL requests per second. -type: long +type: float -- -*`ceph.cluster_status.traffic.read_bytes`*:: +*`aws.rds.throughput.dml`*:: + -- -Cluster read throughput per second - +The average number of inserts, updates, and deletes per second. -type: long -format: bytes +type: float -- -*`ceph.cluster_status.traffic.write_bytes`*:: +*`aws.rds.throughput.insert`*:: + -- -Cluster write throughput per second - +The average number of insert queries per second. -type: long -format: bytes +type: float -- -*`ceph.cluster_status.traffic.read_op_per_sec`*:: +*`aws.rds.throughput.network`*:: + -- -Cluster read iops per second +The amount of network throughput both received from and transmitted to clients by each instance in the Aurora MySQL DB cluster, in bytes per second. -type: long +type: float -- -*`ceph.cluster_status.traffic.write_op_per_sec`*:: +*`aws.rds.throughput.network_receive`*:: + -- -Cluster write iops per second +The incoming (Receive) network traffic on the DB instance, including both customer database traffic and Amazon RDS traffic used for monitoring and replication. -type: long +type: float -- -*`ceph.cluster_status.misplace.total`*:: +*`aws.rds.throughput.network_transmit`*:: + -- -Cluster misplace pg number +The outgoing (Transmit) network traffic on the DB instance, including both customer database traffic and Amazon RDS traffic used for monitoring and replication. -type: long +type: float -- -*`ceph.cluster_status.misplace.objects`*:: +*`aws.rds.throughput.read`*:: + -- -Cluster misplace objects number +The average amount of time taken per disk I/O operation. -type: long +type: float -- -*`ceph.cluster_status.misplace.ratio`*:: +*`aws.rds.throughput.select`*:: + -- -Cluster misplace ratio +The average number of select queries per second. -type: scaled_float +type: float -format: percent +-- + +*`aws.rds.throughput.update`*:: ++ +-- +The average number of update queries per second. + + +type: float -- -*`ceph.cluster_status.degraded.total`*:: +*`aws.rds.throughput.write`*:: + -- -Cluster degraded pg number +The average number of bytes written to disk per second. -type: long +type: float -- -*`ceph.cluster_status.degraded.objects`*:: +*`aws.rds.latency.commit`*:: + -- -Cluster degraded objects number +The amount of latency for commit operations, in milliseconds. -type: long +type: float + +format: duration -- -*`ceph.cluster_status.degraded.ratio`*:: +*`aws.rds.latency.ddl`*:: + -- -Cluster degraded ratio +The amount of latency for data definition language (DDL) requests, in milliseconds. -type: scaled_float +type: float -format: percent +format: duration -- -*`ceph.cluster_status.pg.data_bytes`*:: +*`aws.rds.latency.dml`*:: + -- -Cluster pg data bytes +The amount of latency for inserts, updates, and deletes, in milliseconds. -type: long +type: float -format: bytes +format: duration -- -*`ceph.cluster_status.pg.avail_bytes`*:: +*`aws.rds.latency.insert`*:: + -- -Cluster available bytes +The amount of latency for insert queries, in milliseconds. -type: long +type: float -format: bytes +format: duration -- -*`ceph.cluster_status.pg.total_bytes`*:: +*`aws.rds.latency.read`*:: + -- -Cluster total bytes +The average amount of time taken per disk I/O operation. -type: long +type: float -format: bytes +format: duration -- -*`ceph.cluster_status.pg.used_bytes`*:: +*`aws.rds.latency.select`*:: + -- -Cluster used bytes +The amount of latency for select queries, in milliseconds. -type: long +type: float -format: bytes +format: duration -- -*`ceph.cluster_status.pg_state.state_name`*:: +*`aws.rds.latency.update`*:: + -- -Pg state description +The amount of latency for update queries, in milliseconds. -type: long +type: float + +format: duration -- -*`ceph.cluster_status.pg_state.count`*:: +*`aws.rds.latency.write`*:: + -- -Shows how many pgs are in state of pg_state.state_name +The average amount of time taken per disk I/O operation. -type: long +type: float + +format: duration -- -*`ceph.cluster_status.pg_state.version`*:: +*`aws.rds.disk_usage.bin_log.bytes`*:: + -- -Cluster status version +The amount of disk space occupied by binary logs on the master. Applies to MySQL read replicas. type: long +format: bytes + -- -*`ceph.cluster_status.osd.full`*:: +*`aws.rds.disk_usage.replication_slot.mb`*:: + -- -Is osd full +The disk space used by replication slot files. Applies to PostgreSQL. -type: boolean +type: long -- -*`ceph.cluster_status.osd.nearfull`*:: +*`aws.rds.disk_usage.transaction_logs.mb`*:: + -- -Is osd near full +The disk space used by transaction logs. Applies to PostgreSQL. -type: boolean +type: long -- -*`ceph.cluster_status.osd.num_osds`*:: +*`aws.rds.transactions.active`*:: + -- -Shows how many osds in the cluster +The average number of current transactions executing on an Aurora database instance per second. type: long -- -*`ceph.cluster_status.osd.num_up_osds`*:: +*`aws.rds.transactions.blocked`*:: + -- -Shows how many osds are on the state of UP +The average number of transactions in the database that are blocked per second. type: long -- -*`ceph.cluster_status.osd.num_in_osds`*:: +*`aws.rds.db_instance.db_cluster_identifier`*:: + -- -Shows how many osds are on the state of IN +This identifier is the unique key that identifies a DB cluster specifically for Amazon Aurora DB cluster. -type: long +type: keyword -- -*`ceph.cluster_status.osd.num_remapped_pgs`*:: +*`aws.rds.db_instance.role`*:: + -- -Shows how many osds are on the state of REMAPPED +DB roles like WRITER or READER, specifically for Amazon Aurora DB cluster. -type: long +type: keyword -- -*`ceph.cluster_status.osd.epoch`*:: +*`aws.rds.db_instance.engine_name`*:: + -- -epoch number +Each DB instance runs a DB engine, like MySQL, MariaDB, PostgreSQL and etc. -type: long +type: keyword -- [float] -=== monitor_health +=== s3_daily_storage -monitor_health stats data +`s3_daily_storage` contains the daily storage metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by AWS S3. -*`ceph.monitor_health.available.pct`*:: +*`aws.s3_daily_storage.bucket.size.bytes`*:: + -- -Available percent of the MON +The amount of data in bytes stored in a bucket. type: long +format: bytes + -- -*`ceph.monitor_health.health`*:: +*`aws.s3_daily_storage.number_of_objects`*:: + -- -Health of the MON +The total number of objects stored in a bucket for all storage classes. -type: keyword +type: long -- -*`ceph.monitor_health.available.kb`*:: +[float] +=== s3_request + +`s3_request` contains request metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by AWS S3. + + + +*`aws.s3_request.requests.total`*:: + -- -Available KB of the MON +The total number of HTTP requests made to an Amazon S3 bucket, regardless of type. type: long -- -*`ceph.monitor_health.total.kb`*:: +*`aws.s3_request.requests.get`*:: + -- -Total KB of the MON +The number of HTTP GET requests made for objects in an Amazon S3 bucket. type: long -- -*`ceph.monitor_health.used.kb`*:: +*`aws.s3_request.requests.put`*:: + -- -Used KB of the MON +The number of HTTP PUT requests made for objects in an Amazon S3 bucket. type: long -- -*`ceph.monitor_health.last_updated`*:: +*`aws.s3_request.requests.delete`*:: + -- -Time when was updated +The number of HTTP DELETE requests made for objects in an Amazon S3 bucket. -type: date +type: long -- -*`ceph.monitor_health.name`*:: +*`aws.s3_request.requests.head`*:: + -- -Name of the MON +The number of HTTP HEAD requests made to an Amazon S3 bucket. -type: keyword +type: long -- -*`ceph.monitor_health.store_stats.log.bytes`*:: +*`aws.s3_request.requests.post`*:: + -- -Log bytes of MON +The number of HTTP POST requests made to an Amazon S3 bucket. type: long -format: bytes - -- -*`ceph.monitor_health.store_stats.misc.bytes`*:: +*`aws.s3_request.requests.select`*:: + -- -Misc bytes of MON +The number of Amazon S3 SELECT Object Content requests made for objects in an Amazon S3 bucket. type: long -format: bytes - -- -*`ceph.monitor_health.store_stats.sst.bytes`*:: +*`aws.s3_request.requests.select_scanned.bytes`*:: + -- -SST bytes of MON +The number of bytes of data scanned with Amazon S3 SELECT Object Content requests in an Amazon S3 bucket. type: long @@ -3092,10 +2645,10 @@ format: bytes -- -*`ceph.monitor_health.store_stats.total.bytes`*:: +*`aws.s3_request.requests.select_returned.bytes`*:: + -- -Total bytes of MON +The number of bytes of data returned with Amazon S3 SELECT Object Content requests in an Amazon S3 bucket. type: long @@ -3104,907 +2657,911 @@ format: bytes -- -*`ceph.monitor_health.store_stats.last_updated`*:: +*`aws.s3_request.requests.list`*:: + -- -Last updated +The number of HTTP requests that list the contents of a bucket. type: long -- -[float] -=== osd_df +*`aws.s3_request.downloaded.bytes`*:: ++ +-- +The number bytes downloaded for requests made to an Amazon S3 bucket, where the response includes a body. -ceph osd disk usage information +type: long +format: bytes -*`ceph.osd_df.id`*:: +-- + +*`aws.s3_request.uploaded.bytes`*:: + -- -osd node id +The number bytes uploaded that contain a request body, made to an Amazon S3 bucket. type: long +format: bytes + -- -*`ceph.osd_df.name`*:: +*`aws.s3_request.errors.4xx`*:: + -- -osd node name +The number of HTTP 4xx client error status code requests made to an Amazon S3 bucket with a value of either 0 or 1. -type: keyword +type: long -- -*`ceph.osd_df.device_class`*:: +*`aws.s3_request.errors.5xx`*:: + -- -osd node type, illegal type include hdd, ssd etc. +The number of HTTP 5xx server error status code requests made to an Amazon S3 bucket with a value of either 0 or 1. -type: keyword +type: long -- -*`ceph.osd_df.total.byte`*:: +*`aws.s3_request.latency.first_byte.ms`*:: + -- -osd disk total volume +The per-request time from the complete request being received by an Amazon S3 bucket to when the response starts to be returned. type: long -format: bytes +format: duration -- -*`ceph.osd_df.used.byte`*:: +*`aws.s3_request.latency.total_request.ms`*:: + -- -osd disk usage volume +The elapsed per-request time from the first byte received to the last byte sent to an Amazon S3 bucket. type: long -format: bytes +format: duration -- -*`ceph.osd_df.available.bytes`*:: -+ --- -osd disk available volume +[float] +=== sns +`sns` contains the metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by AWS SNS. -type: long -format: bytes +[float] +=== sqs --- +`sqs` contains the metrics that were scraped from AWS CloudWatch which contains monitoring metrics sent by AWS SQS. -*`ceph.osd_df.pg_num`*:: + + +*`aws.sqs.oldest_message_age.sec`*:: + -- -shows how many pg located on this osd +The approximate age of the oldest non-deleted message in the queue. type: long +format: duration + -- -*`ceph.osd_df.used.pct`*:: +*`aws.sqs.messages.delayed`*:: + -- -osd disk usage percentage +TThe number of messages in the queue that are delayed and not available for reading immediately. -type: scaled_float - -format: percent +type: long -- -[float] -=== osd_tree - -ceph osd tree info - - - -*`ceph.osd_tree.id`*:: +*`aws.sqs.messages.not_visible`*:: + -- -osd or bucket node id +The number of messages that are in flight. type: long -- -*`ceph.osd_tree.name`*:: +*`aws.sqs.messages.visible`*:: + -- -osd or bucket node name +The number of messages available for retrieval from the queue. -type: keyword +type: long -- -*`ceph.osd_tree.type`*:: +*`aws.sqs.messages.deleted`*:: + -- -osd or bucket node type, illegal type include osd, host, root etc. +The number of messages deleted from the queue. -type: keyword +type: long -- -*`ceph.osd_tree.type_id`*:: +*`aws.sqs.messages.received`*:: + -- -osd or bucket node typeID +The number of messages returned by calls to the ReceiveMessage action. type: long -- -*`ceph.osd_tree.children`*:: +*`aws.sqs.messages.sent`*:: + -- -bucket children list, separated by comma. +The number of messages added to a queue. -type: keyword +type: long -- -*`ceph.osd_tree.crush_weight`*:: +*`aws.sqs.empty_receives`*:: + -- -osd node crush weight +The number of ReceiveMessage API calls that did not return a message. -type: float +type: long -- -*`ceph.osd_tree.depth`*:: +*`aws.sqs.sent_message_size.bytes`*:: + -- -node depth +The size of messages added to a queue. type: long +format: bytes + -- -*`ceph.osd_tree.exists`*:: +*`aws.sqs.queue.name`*:: + -- -is node still exist or not(1-yes, 0-no) +SQS queue name -type: boolean +type: keyword -- -*`ceph.osd_tree.primary_affinity`*:: -+ --- -the weight of reading data from primary osd +[float] +=== usage +`usage` contains the metrics from Cloudwatch to track usage of some AWS resources. -type: float --- +[[exported-fields-azure]] +== azure fields -*`ceph.osd_tree.reweight`*:: -+ --- -the reweight of osd +azure module -type: long --- +[float] +=== azure -*`ceph.osd_tree.status`*:: -+ --- -status of osd, it should be up or down -type: keyword --- +[float] +=== resource -*`ceph.osd_tree.device_class`*:: +The resource specified + + + +*`azure.resource.name`*:: + -- -the device class of osd, like hdd, ssd etc. +The name of the resource type: keyword -- -*`ceph.osd_tree.father`*:: +*`azure.resource.type`*:: + -- -the parent node of this osd or bucket node +The type of the resource type: keyword -- -[float] -=== pool_disk +*`azure.resource.group`*:: ++ +-- +The resource group -pool_disk +type: keyword +-- -*`ceph.pool_disk.id`*:: +*`azure.resource.tags.*`*:: + -- -Id of the pool +Azure resource tags. -type: long +type: object -- -*`ceph.pool_disk.name`*:: +*`azure.namespace`*:: + -- -Name of the pool +The namespace selected type: keyword -- -*`ceph.pool_disk.stats.available.bytes`*:: +*`azure.subscription_id`*:: + -- -Available bytes of the pool - +The subscription ID -type: long -format: bytes +type: keyword -- -*`ceph.pool_disk.stats.objects`*:: +*`azure.dimensions.*`*:: + -- -Number of objects of the pool +Azure metric dimensions. -type: long +type: object -- -*`ceph.pool_disk.stats.used.bytes`*:: +*`azure.compute_vm.*.*`*:: + -- -Used bytes of the pool - +compute_vm -type: long -format: bytes +type: object -- -*`ceph.pool_disk.stats.used.kb`*:: +*`azure.compute_vm_scaleset.*.*`*:: + -- -Used kb of the pool +compute_vm_scaleset -type: long +type: object -- -[[exported-fields-cloud]] -== Cloud provider metadata fields +[float] +=== monitor -Metadata from cloud providers added by the add_cloud_metadata processor. +monitor -*`cloud.project.id`*:: +*`azure.monitor.metrics.*.*`*:: + -- -Name of the project in Google Cloud. +Metrics returned. -example: project-x +type: object -- -*`cloud.image.id`*:: +*`azure.storage.*.*`*:: + -- -Image ID for the cloud instance. +storage account -example: ami-abcd1234 +type: object -- -*`meta.cloud.provider`*:: -+ --- -type: alias +[[exported-fields-beat-common]] +== Beat fields -alias to: cloud.provider +Contains common beat fields available in all event types. --- -*`meta.cloud.instance_id`*:: + +*`agent.hostname`*:: + -- -type: alias +Hostname of the agent. -alias to: cloud.instance.id +type: keyword -- -*`meta.cloud.instance_name`*:: +*`beat.timezone`*:: + -- type: alias -alias to: cloud.instance.name +alias to: event.timezone -- -*`meta.cloud.machine_type`*:: +*`fields`*:: + -- -type: alias +Contains user configurable fields. -alias to: cloud.machine.type + +type: object -- -*`meta.cloud.availability_zone`*:: +*`beat.name`*:: + -- type: alias -alias to: cloud.availability_zone +alias to: host.name -- -*`meta.cloud.project_id`*:: +*`beat.hostname`*:: + -- type: alias -alias to: cloud.project.id +alias to: agent.hostname -- -*`meta.cloud.region`*:: +*`timeseries.instance`*:: + -- -type: alias +Time series instance id -alias to: cloud.region +type: keyword -- -[[exported-fields-cockroachdb]] -== CockroachDB fields - -CockroachDB module +[[exported-fields-beat]] +== Beat fields +Beat module -[[exported-fields-common]] -== Common fields +[float] +=== beat -Contains common fields available in all event types. -*`metricset.module`*:: +*`beat.id`*:: + -- -The name of the module that generated the event. - +Beat ID. -type: alias -alias to: event.module +type: keyword -- -*`metricset.name`*:: +*`beat.type`*:: + -- -The name of the metricset that generated the event. +Beat type. --- +type: keyword -*`metricset.period`*:: -+ -- -Current data collection period for this event in milliseconds. +[float] +=== state -type: integer +Beat state --- -*`service.address`*:: + +*`beat.state.management.enabled`*:: + -- -Address of the machine where the service is running. This field may not be present when the data was collected locally. +Is central management enabled? + +type: boolean -- -*`service.hostname`*:: +*`beat.state.module.count`*:: + -- -Host name of the machine where the service is running. +Number of modules enabled + +type: integer -- -*`type`*:: +*`beat.state.output.name`*:: + -- -The document type. Always set to "doc". - +Name of output used by Beat -example: metricsets -required: True +type: keyword -- -*`systemd.fragment_path`*:: +*`beat.state.queue.name`*:: + -- -the location of the systemd unit path +Name of queue being used by Beat + type: keyword -- -*`systemd.unit`*:: +[float] +=== stats + +Beat stats + + + +*`beat.stats.uptime.ms`*:: + -- -the unit name of the systemd service +Beat uptime -type: keyword --- +type: long -[[exported-fields-consul]] -== consul fields +-- -Consul module +*`beat.stats.runtime.goroutines`*:: ++ +-- +Number of goroutines running in Beat +type: long +-- [float] -=== agent +=== libbeat + +Fields common to all Beats + -Agent Metricset fetches metrics information from a Consul instance running as Agent +[float] +=== output +Output stats -*`consul.agent.autopilot.healthy`*:: + +*`beat.stats.libbeat.output.type`*:: + -- -Overall health of the local server cluster +Type of output -type: boolean + +type: keyword -- [float] -=== runtime +=== events -Runtime related metrics +Event counters -*`consul.agent.runtime.sys.bytes`*:: +*`beat.stats.libbeat.output.events.acked`*:: + -- -Number of bytes of memory obtained from the OS. +Number of events acknowledged + type: long -- -*`consul.agent.runtime.malloc_count`*:: +*`beat.stats.libbeat.output.events.active`*:: + -- -Heap objects allocated +Number of active events + type: long -- -*`consul.agent.runtime.heap_objects`*:: +*`beat.stats.libbeat.output.events.batches`*:: + -- -Objects allocated on the heap and is a general memory pressure indicator. This may burst from time to time but should return to a steady state value. +Number of event batches + type: long -- -*`consul.agent.runtime.goroutines`*:: +*`beat.stats.libbeat.output.events.dropped`*:: + -- -Running goroutines and is a general load pressure indicator. This may burst from time to time but should return to a steady state value. +Number of events dropped + type: long -- - -*`consul.agent.runtime.alloc.bytes`*:: +*`beat.stats.libbeat.output.events.duplicates`*:: + -- -Bytes allocated by the Consul process. +Number of events duplicated + type: long -- -[float] -=== garbage_collector - -Garbage collector metrics - - -*`consul.agent.runtime.garbage_collector.runs`*:: +*`beat.stats.libbeat.output.events.failed`*:: + -- -Garbage collector total executions +Number of events failed + type: long -- -[float] -=== pause - -Time that the garbage collector has paused the app - - - -*`consul.agent.runtime.garbage_collector.pause.current.ns`*:: +*`beat.stats.libbeat.output.events.toomany`*:: + -- -Garbage collector pause time in nanoseconds +Number of too many events + type: long -- - -*`consul.agent.runtime.garbage_collector.pause.total.ns`*:: +*`beat.stats.libbeat.output.events.total`*:: + -- -Nanoseconds consumed by stop-the-world garbage collection pauses since Consul started. +Total number of events + type: long -- -[[exported-fields-coredns]] -== coredns fields - -coredns Module - - - -[float] -=== coredns - -`coredns` contains statistics that were read from coreDNS - - - [float] -=== stats +=== read -Contains statistics related to the coreDNS service +Read stats -*`coredns.stats.panic.count`*:: +*`beat.stats.libbeat.output.read.bytes`*:: + -- -Total number of panics +Number of bytes read type: long -- -*`coredns.stats.dns.request.count`*:: +*`beat.stats.libbeat.output.read.errors`*:: + -- -Total query count +Number of read errors type: long -- -*`coredns.stats.dns.request.duration.ns.bucket.*`*:: -+ --- -Request duration histogram buckets in nanoseconds +[float] +=== write +Write stats -type: object --- -*`coredns.stats.dns.request.duration.ns.sum`*:: +*`beat.stats.libbeat.output.write.bytes`*:: + -- -Requests duration, sum of durations in nanoseconds +Number of bytes written type: long -format: duration - -- -*`coredns.stats.dns.request.duration.ns.count`*:: +*`beat.stats.libbeat.output.write.errors`*:: + -- -Requests duration, number of requests +Number of write errors type: long -- -*`coredns.stats.dns.request.size.bytes.bucket.*`*:: -+ --- -Request Size histogram buckets +[[exported-fields-ceph]] +== Ceph fields +Ceph module -type: object --- -*`coredns.stats.dns.request.size.bytes.sum`*:: -+ --- -Request Size histogram sum +[float] +=== ceph +`ceph` contains the metrics that were scraped from CEPH. -type: long --- -*`coredns.stats.dns.request.size.bytes.count`*:: +[float] +=== cluster_disk + +cluster_disk + + + +*`ceph.cluster_disk.available.bytes`*:: + -- -Request Size histogram count +Available bytes of the cluster type: long +format: bytes + -- -*`coredns.stats.dns.request.do.count`*:: +*`ceph.cluster_disk.total.bytes`*:: + -- -Number of queries that have the DO bit set +Total bytes of the cluster type: long +format: bytes + -- -*`coredns.stats.dns.request.type.count`*:: +*`ceph.cluster_disk.used.bytes`*:: + -- -Counter of queries per zone and type +Used bytes of the cluster type: long +format: bytes + -- -*`coredns.stats.type`*:: +[float] +=== cluster_health + +cluster_health + + + +*`ceph.cluster_health.overall_status`*:: + -- -Holds the query type of the request +Overall status of the cluster type: keyword -- -*`coredns.stats.dns.response.rcode.count`*:: +*`ceph.cluster_health.timechecks.epoch`*:: + -- -Counter of responses per zone and rcode +Map version type: long -- -*`coredns.stats.rcode`*:: +*`ceph.cluster_health.timechecks.round.value`*:: + -- -Holds the rcode of the response +timecheck round -type: keyword +type: long -- -*`coredns.stats.family`*:: +*`ceph.cluster_health.timechecks.round.status`*:: + -- -The address family of the transport (1 = IP (IP version 4), 2 = IP6 (IP version 6)) +Status of the round type: keyword -- -*`coredns.stats.dns.response.size.bytes.bucket.*`*:: -+ --- -Response Size histogram buckets +[float] +=== cluster_status +cluster_status -type: object --- -*`coredns.stats.dns.response.size.bytes.sum`*:: +*`ceph.cluster_status.version`*:: + -- -Response Size histogram sum +Ceph Status version type: long -- -*`coredns.stats.dns.response.size.bytes.count`*:: +*`ceph.cluster_status.traffic.read_bytes`*:: + -- -Response Size histogram count +Cluster read throughput per second type: long +format: bytes + -- -*`coredns.stats.server`*:: +*`ceph.cluster_status.traffic.write_bytes`*:: + -- -The server responsible for the request +Cluster write throughput per second -type: keyword +type: long + +format: bytes -- -*`coredns.stats.zone`*:: +*`ceph.cluster_status.traffic.read_op_per_sec`*:: + -- -The zonename used for the request/response +Cluster read iops per second -type: keyword +type: long -- -*`coredns.stats.proto`*:: +*`ceph.cluster_status.traffic.write_op_per_sec`*:: + -- -The transport of the response ("udp" or "tcp") +Cluster write iops per second -type: keyword +type: long -- -*`coredns.stats.dns.cache.hits.count`*:: +*`ceph.cluster_status.misplace.total`*:: + -- -Cache hits count for the cache plugin +Cluster misplace pg number type: long -- -*`coredns.stats.dns.cache.misses.count`*:: +*`ceph.cluster_status.misplace.objects`*:: + -- -Cache misses count for the cache plugin +Cluster misplace objects number type: long -- -[[exported-fields-couchbase]] -== Couchbase fields - -Metrics collected from Couchbase servers. - - +*`ceph.cluster_status.misplace.ratio`*:: ++ +-- +Cluster misplace ratio -[float] -=== couchbase -`couchbase` contains the metrics that were scraped from Couchbase. +type: scaled_float +format: percent +-- -[float] -=== bucket +*`ceph.cluster_status.degraded.total`*:: ++ +-- +Cluster degraded pg number -Couchbase bucket metrics. +type: long +-- -*`couchbase.bucket.name`*:: +*`ceph.cluster_status.degraded.objects`*:: + -- -Name of the bucket. +Cluster degraded objects number -type: keyword +type: long -- -*`couchbase.bucket.type`*:: +*`ceph.cluster_status.degraded.ratio`*:: + -- -Type of the bucket. +Cluster degraded ratio -type: keyword +type: scaled_float + +format: percent -- -*`couchbase.bucket.data.used.bytes`*:: +*`ceph.cluster_status.pg.data_bytes`*:: + -- -Size of user data within buckets of the specified state that are resident in RAM. +Cluster pg data bytes type: long @@ -4013,20 +3570,22 @@ format: bytes -- -*`couchbase.bucket.disk.fetches`*:: +*`ceph.cluster_status.pg.avail_bytes`*:: + -- -Number of disk fetches. +Cluster available bytes type: long +format: bytes + -- -*`couchbase.bucket.disk.used.bytes`*:: +*`ceph.cluster_status.pg.total_bytes`*:: + -- -Amount of disk used (bytes). +Cluster total bytes type: long @@ -4035,10 +3594,10 @@ format: bytes -- -*`couchbase.bucket.memory.used.bytes`*:: +*`ceph.cluster_status.pg.used_bytes`*:: + -- -Amount of memory used by the bucket (bytes). +Cluster used bytes type: long @@ -4047,175 +3606,187 @@ format: bytes -- -*`couchbase.bucket.quota.ram.bytes`*:: +*`ceph.cluster_status.pg_state.state_name`*:: + -- -Amount of RAM used by the bucket (bytes). +Pg state description type: long -format: bytes - -- -*`couchbase.bucket.quota.use.pct`*:: +*`ceph.cluster_status.pg_state.count`*:: + -- -Percentage of RAM used (for active objects) against the configured bucket size (%). - +Shows how many pgs are in state of pg_state.state_name -type: scaled_float -format: percent +type: long -- -*`couchbase.bucket.ops_per_sec`*:: +*`ceph.cluster_status.pg_state.version`*:: + -- -Number of operations per second. +Cluster status version type: long -- -*`couchbase.bucket.item_count`*:: +*`ceph.cluster_status.osd.full`*:: + -- -Number of items associated with the bucket. +Is osd full -type: long +type: boolean -- -[float] -=== cluster +*`ceph.cluster_status.osd.nearfull`*:: ++ +-- +Is osd near full -Couchbase cluster metrics. +type: boolean +-- -*`couchbase.cluster.hdd.free.bytes`*:: +*`ceph.cluster_status.osd.num_osds`*:: + -- -Free hard drive space in the cluster (bytes). +Shows how many osds in the cluster type: long -format: bytes - -- -*`couchbase.cluster.hdd.quota.total.bytes`*:: +*`ceph.cluster_status.osd.num_up_osds`*:: + -- -Hard drive quota total for the cluster (bytes). +Shows how many osds are on the state of UP type: long -format: bytes - -- -*`couchbase.cluster.hdd.total.bytes`*:: +*`ceph.cluster_status.osd.num_in_osds`*:: + -- -Total hard drive space available to the cluster (bytes). +Shows how many osds are on the state of IN type: long -format: bytes - -- -*`couchbase.cluster.hdd.used.value.bytes`*:: +*`ceph.cluster_status.osd.num_remapped_pgs`*:: + -- -Hard drive space used by the cluster (bytes). +Shows how many osds are on the state of REMAPPED type: long -format: bytes - -- -*`couchbase.cluster.hdd.used.by_data.bytes`*:: +*`ceph.cluster_status.osd.epoch`*:: + -- -Hard drive space used by the data in the cluster (bytes). +epoch number type: long -format: bytes - -- -*`couchbase.cluster.max_bucket_count`*:: +[float] +=== monitor_health + +monitor_health stats data + + + +*`ceph.monitor_health.available.pct`*:: + -- -Max bucket count setting. +Available percent of the MON type: long -- -*`couchbase.cluster.quota.index_memory.mb`*:: +*`ceph.monitor_health.health`*:: + -- -Memory quota setting for the Index service (Mbyte). +Health of the MON -type: long +type: keyword -- -*`couchbase.cluster.quota.memory.mb`*:: +*`ceph.monitor_health.available.kb`*:: + -- -Memory quota setting for the cluster (Mbyte). +Available KB of the MON type: long -- -*`couchbase.cluster.ram.quota.total.value.bytes`*:: +*`ceph.monitor_health.total.kb`*:: + -- -RAM quota total for the cluster (bytes). +Total KB of the MON type: long -format: bytes - -- -*`couchbase.cluster.ram.quota.total.per_node.bytes`*:: +*`ceph.monitor_health.used.kb`*:: + -- -RAM quota used by the current node in the cluster (bytes). +Used KB of the MON type: long -format: bytes +-- + +*`ceph.monitor_health.last_updated`*:: ++ +-- +Time when was updated + + +type: date -- -*`couchbase.cluster.ram.quota.used.value.bytes`*:: +*`ceph.monitor_health.name`*:: + -- -RAM quota used by the cluster (bytes). +Name of the MON + + +type: keyword + +-- + +*`ceph.monitor_health.store_stats.log.bytes`*:: ++ +-- +Log bytes of MON type: long @@ -4224,10 +3795,10 @@ format: bytes -- -*`couchbase.cluster.ram.quota.used.per_node.bytes`*:: +*`ceph.monitor_health.store_stats.misc.bytes`*:: + -- -Ram quota used by the current node in the cluster (bytes) +Misc bytes of MON type: long @@ -4236,10 +3807,10 @@ format: bytes -- -*`couchbase.cluster.ram.total.bytes`*:: +*`ceph.monitor_health.store_stats.sst.bytes`*:: + -- -Total RAM available to cluster (bytes). +SST bytes of MON type: long @@ -4248,10 +3819,10 @@ format: bytes -- -*`couchbase.cluster.ram.used.value.bytes`*:: +*`ceph.monitor_health.store_stats.total.bytes`*:: + -- -RAM used by the cluster (bytes). +Total bytes of MON type: long @@ -4260,957 +3831,907 @@ format: bytes -- -*`couchbase.cluster.ram.used.by_data.bytes`*:: +*`ceph.monitor_health.store_stats.last_updated`*:: + -- -RAM used by the data in the cluster (bytes). +Last updated type: long -format: bytes - -- [float] -=== node +=== osd_df -Couchbase node metrics. +ceph osd disk usage information -*`couchbase.node.cmd_get`*:: +*`ceph.osd_df.id`*:: + -- -Number of get commands +osd node id type: long -- -*`couchbase.node.couch.docs.disk_size.bytes`*:: +*`ceph.osd_df.name`*:: + -- -Amount of disk space used by Couch docs (bytes). - +osd node name -type: long -format: bytes +type: keyword -- -*`couchbase.node.couch.docs.data_size.bytes`*:: +*`ceph.osd_df.device_class`*:: + -- -Data size of Couch docs associated with a node (bytes). - +osd node type, illegal type include hdd, ssd etc. -type: long -format: bytes +type: keyword -- -*`couchbase.node.couch.spatial.data_size.bytes`*:: +*`ceph.osd_df.total.byte`*:: + -- -Size of object data for spatial views (bytes). +osd disk total volume type: long +format: bytes + -- -*`couchbase.node.couch.spatial.disk_size.bytes`*:: +*`ceph.osd_df.used.byte`*:: + -- -Amount of disk space used by spatial views (bytes). +osd disk usage volume type: long +format: bytes + -- -*`couchbase.node.couch.views.disk_size.bytes`*:: +*`ceph.osd_df.available.bytes`*:: + -- -Amount of disk space used by Couch views (bytes). +osd disk available volume type: long +format: bytes + -- -*`couchbase.node.couch.views.data_size.bytes`*:: +*`ceph.osd_df.pg_num`*:: + -- -Size of object data for Couch views (bytes). +shows how many pg located on this osd type: long -- -*`couchbase.node.cpu_utilization_rate.pct`*:: +*`ceph.osd_df.used.pct`*:: + -- -The CPU utilization rate (%). +osd disk usage percentage type: scaled_float --- - -*`couchbase.node.current_items.value`*:: -+ --- -Number of current items. - - -type: long +format: percent -- -*`couchbase.node.current_items.total`*:: -+ --- -Total number of items associated with the node. +[float] +=== osd_tree +ceph osd tree info -type: long --- -*`couchbase.node.ep_bg_fetched`*:: +*`ceph.osd_tree.id`*:: + -- -Number of disk fetches performed since the server was started. +osd or bucket node id type: long -- -*`couchbase.node.get_hits`*:: +*`ceph.osd_tree.name`*:: + -- -Number of get hits. +osd or bucket node name -type: long +type: keyword -- -*`couchbase.node.hostname`*:: +*`ceph.osd_tree.type`*:: + -- -The hostname of the node. +osd or bucket node type, illegal type include osd, host, root etc. type: keyword -- -*`couchbase.node.mcd_memory.allocated.bytes`*:: +*`ceph.osd_tree.type_id`*:: + -- -Amount of memcached memory allocated (bytes). +osd or bucket node typeID type: long -format: bytes - -- -*`couchbase.node.mcd_memory.reserved.bytes`*:: +*`ceph.osd_tree.children`*:: + -- -Amount of memcached memory reserved (bytes). +bucket children list, separated by comma. -type: long +type: keyword -- -*`couchbase.node.memory.free.bytes`*:: +*`ceph.osd_tree.crush_weight`*:: + -- -Amount of memory free for the node (bytes). +osd node crush weight -type: long +type: float -- -*`couchbase.node.memory.total.bytes`*:: +*`ceph.osd_tree.depth`*:: + -- -Total memory available to the node (bytes). +node depth type: long -- -*`couchbase.node.memory.used.bytes`*:: +*`ceph.osd_tree.exists`*:: + -- -Memory used by the node (bytes). +is node still exist or not(1-yes, 0-no) -type: long +type: boolean -- -*`couchbase.node.ops`*:: +*`ceph.osd_tree.primary_affinity`*:: + -- -Number of operations performed on Couchbase. +the weight of reading data from primary osd -type: long +type: float -- -*`couchbase.node.swap.total.bytes`*:: +*`ceph.osd_tree.reweight`*:: + -- -Total swap size allocated (bytes). +the reweight of osd type: long -- -*`couchbase.node.swap.used.bytes`*:: +*`ceph.osd_tree.status`*:: + -- -Amount of swap space used (bytes). +status of osd, it should be up or down -type: long +type: keyword -- -*`couchbase.node.uptime.sec`*:: +*`ceph.osd_tree.device_class`*:: + -- -Time during which the node was in operation (sec). +the device class of osd, like hdd, ssd etc. -type: long +type: keyword -- -*`couchbase.node.vb_replica_curr_items`*:: +*`ceph.osd_tree.father`*:: + -- -Number of items/documents that are replicas. +the parent node of this osd or bucket node -type: long +type: keyword -- -[[exported-fields-couchdb]] -== couchdb fields - -couchdb module - - - -[float] -=== couchdb - - - - [float] -=== server +=== pool_disk -Contains CouchDB server stats +pool_disk -[float] -=== httpd +*`ceph.pool_disk.id`*:: ++ +-- +Id of the pool -HTTP statistics +type: long +-- -*`couchdb.server.httpd.view_reads`*:: +*`ceph.pool_disk.name`*:: + -- -Number of view reads +Name of the pool -type: long +type: keyword -- -*`couchdb.server.httpd.bulk_requests`*:: +*`ceph.pool_disk.stats.available.bytes`*:: + -- -Number of bulk requests +Available bytes of the pool type: long +format: bytes + -- -*`couchdb.server.httpd.clients_requesting_changes`*:: +*`ceph.pool_disk.stats.objects`*:: + -- -Number of clients for continuous _changes +Number of objects of the pool type: long -- -*`couchdb.server.httpd.temporary_view_reads`*:: +*`ceph.pool_disk.stats.used.bytes`*:: + -- -Number of temporary view reads +Used bytes of the pool type: long +format: bytes + -- -*`couchdb.server.httpd.requests`*:: +*`ceph.pool_disk.stats.used.kb`*:: + -- -Number of HTTP requests +Used kb of the pool type: long -- -[float] -=== httpd_request_methods +[[exported-fields-cloud]] +== Cloud provider metadata fields -HTTP request methods +Metadata from cloud providers added by the add_cloud_metadata processor. -*`couchdb.server.httpd_request_methods.COPY`*:: +*`cloud.project.id`*:: + -- -Number of HTTP COPY requests +Name of the project in Google Cloud. -type: long +example: project-x -- -*`couchdb.server.httpd_request_methods.HEAD`*:: +*`cloud.image.id`*:: + -- -Number of HTTP HEAD requests +Image ID for the cloud instance. -type: long +example: ami-abcd1234 -- -*`couchdb.server.httpd_request_methods.POST`*:: +*`meta.cloud.provider`*:: + -- -Number of HTTP POST requests - +type: alias -type: long +alias to: cloud.provider -- -*`couchdb.server.httpd_request_methods.DELETE`*:: +*`meta.cloud.instance_id`*:: + -- -Number of HTTP DELETE requests - +type: alias -type: long +alias to: cloud.instance.id -- -*`couchdb.server.httpd_request_methods.GET`*:: +*`meta.cloud.instance_name`*:: + -- -Number of HTTP GET requests - +type: alias -type: long +alias to: cloud.instance.name -- -*`couchdb.server.httpd_request_methods.PUT`*:: +*`meta.cloud.machine_type`*:: + -- -Number of HTTP PUT requests - +type: alias -type: long +alias to: cloud.machine.type -- -[float] -=== httpd_status_codes - -HTTP status codes statistics +*`meta.cloud.availability_zone`*:: ++ +-- +type: alias +alias to: cloud.availability_zone +-- -*`couchdb.server.httpd_status_codes.200`*:: +*`meta.cloud.project_id`*:: + -- -Number of HTTP 200 OK responses - +type: alias -type: long +alias to: cloud.project.id -- -*`couchdb.server.httpd_status_codes.201`*:: +*`meta.cloud.region`*:: + -- -Number of HTTP 201 Created responses - +type: alias -type: long +alias to: cloud.region -- -*`couchdb.server.httpd_status_codes.202`*:: -+ --- -Number of HTTP 202 Accepted responses +[[exported-fields-cockroachdb]] +== CockroachDB fields +CockroachDB module -type: long --- -*`couchdb.server.httpd_status_codes.301`*:: -+ --- -Number of HTTP 301 Moved Permanently responses +[[exported-fields-common]] +== Common fields -type: long +Contains common fields available in all event types. --- -*`couchdb.server.httpd_status_codes.304`*:: + +*`metricset.module`*:: + -- -Number of HTTP 304 Not Modified responses +The name of the module that generated the event. -type: long +type: alias + +alias to: event.module -- -*`couchdb.server.httpd_status_codes.400`*:: +*`metricset.name`*:: + -- -Number of HTTP 400 Bad Request responses - +The name of the metricset that generated the event. -type: long -- -*`couchdb.server.httpd_status_codes.401`*:: +*`metricset.period`*:: + -- -Number of HTTP 401 Unauthorized responses +Current data collection period for this event in milliseconds. -type: long +type: integer -- -*`couchdb.server.httpd_status_codes.403`*:: +*`service.address`*:: + -- -Number of HTTP 403 Forbidden responses +Address of the machine where the service is running. This field may not be present when the data was collected locally. -type: long - -- -*`couchdb.server.httpd_status_codes.404`*:: +*`service.hostname`*:: + -- -Number of HTTP 404 Not Found responses - +Host name of the machine where the service is running. -type: long -- -*`couchdb.server.httpd_status_codes.405`*:: +*`type`*:: + -- -Number of HTTP 405 Method Not Allowed responses +The document type. Always set to "doc". -type: long +example: metricsets + +required: True -- -*`couchdb.server.httpd_status_codes.409`*:: +*`systemd.fragment_path`*:: + -- -Number of HTTP 409 Conflict responses - +the location of the systemd unit path -type: long +type: keyword -- -*`couchdb.server.httpd_status_codes.412`*:: +*`systemd.unit`*:: + -- -Number of HTTP 412 Precondition Failed responses - +the unit name of the systemd service -type: long +type: keyword -- -*`couchdb.server.httpd_status_codes.500`*:: -+ --- -Number of HTTP 500 Internal Server Error responses +[[exported-fields-consul]] +== consul fields + +Consul module -type: long --- [float] -=== couchdb +=== agent -couchdb statistics +Agent Metricset fetches metrics information from a Consul instance running as Agent -*`couchdb.server.couchdb.database_writes`*:: + +*`consul.agent.autopilot.healthy`*:: + -- -Number of times a database was changed - +Overall health of the local server cluster -type: long +type: boolean -- -*`couchdb.server.couchdb.open_databases`*:: -+ --- -Number of open databases +[float] +=== runtime +Runtime related metrics -type: long --- -*`couchdb.server.couchdb.auth_cache_misses`*:: +*`consul.agent.runtime.sys.bytes`*:: + -- -Number of authentication cache misses - +Number of bytes of memory obtained from the OS. type: long -- -*`couchdb.server.couchdb.request_time`*:: +*`consul.agent.runtime.malloc_count`*:: + -- -Length of a request inside CouchDB without MochiWeb - +Heap objects allocated type: long -- -*`couchdb.server.couchdb.database_reads`*:: +*`consul.agent.runtime.heap_objects`*:: + -- -Number of times a document was read from a database - +Objects allocated on the heap and is a general memory pressure indicator. This may burst from time to time but should return to a steady state value. type: long -- -*`couchdb.server.couchdb.auth_cache_hits`*:: +*`consul.agent.runtime.goroutines`*:: + -- -Number of authentication cache hits - +Running goroutines and is a general load pressure indicator. This may burst from time to time but should return to a steady state value. type: long -- -*`couchdb.server.couchdb.open_os_files`*:: + +*`consul.agent.runtime.alloc.bytes`*:: + -- -Number of file descriptors CouchDB has open - +Bytes allocated by the Consul process. type: long -- -[[exported-fields-docker-processor]] -== Docker fields - -Docker stats collected from Docker. - +[float] +=== garbage_collector +Garbage collector metrics -*`docker.container.id`*:: +*`consul.agent.runtime.garbage_collector.runs`*:: + -- -type: alias +Garbage collector total executions -alias to: container.id +type: long -- -*`docker.container.image`*:: -+ --- -type: alias +[float] +=== pause -alias to: container.image.name +Time that the garbage collector has paused the app --- -*`docker.container.name`*:: + +*`consul.agent.runtime.garbage_collector.pause.current.ns`*:: + -- -type: alias +Garbage collector pause time in nanoseconds -alias to: container.name +type: long -- -*`docker.container.labels`*:: + +*`consul.agent.runtime.garbage_collector.pause.total.ns`*:: + -- -Image labels. - +Nanoseconds consumed by stop-the-world garbage collection pauses since Consul started. -type: object +type: long -- -[[exported-fields-docker]] -== Docker fields +[[exported-fields-coredns]] +== coredns fields -Docker stats collected from Docker. +coredns Module [float] -=== docker +=== coredns -Information and statistics about docker's running containers. +`coredns` contains statistics that were read from coreDNS [float] -=== container +=== stats -Docker container metrics. +Contains statistics related to the coreDNS service -*`docker.container.command`*:: +*`coredns.stats.panic.count`*:: + -- -Command that was executed in the Docker container. +Total number of panics -type: keyword +type: long -- -*`docker.container.created`*:: +*`coredns.stats.dns.request.count`*:: + -- -Date when the container was created. +Total query count -type: date +type: long -- -*`docker.container.status`*:: +*`coredns.stats.dns.request.duration.ns.bucket.*`*:: + -- -Container status. +Request duration histogram buckets in nanoseconds -type: keyword +type: object -- -*`docker.container.ip_addresses`*:: +*`coredns.stats.dns.request.duration.ns.sum`*:: + -- -Container IP addresses. - - -type: ip - --- +Requests duration, sum of durations in nanoseconds -[float] -=== size -Container size metrics. +type: long +format: duration +-- -*`docker.container.size.root_fs`*:: +*`coredns.stats.dns.request.duration.ns.count`*:: + -- -Total size of all the files in the container. +Requests duration, number of requests type: long -- -*`docker.container.size.rw`*:: +*`coredns.stats.dns.request.size.bytes.bucket.*`*:: + -- -Size of the files that have been created or changed since creation. +Request Size histogram buckets -type: long +type: object -- -*`docker.container.tags`*:: +*`coredns.stats.dns.request.size.bytes.sum`*:: + -- -Image tags. +Request Size histogram sum -type: keyword +type: long -- -[float] -=== cpu - -Runtime CPU metrics. - - - -*`docker.cpu.kernel.pct`*:: +*`coredns.stats.dns.request.size.bytes.count`*:: + -- -Percentage of time in kernel space. - +Request Size histogram count -type: scaled_float -format: percent +type: long -- -*`docker.cpu.kernel.norm.pct`*:: +*`coredns.stats.dns.request.do.count`*:: + -- -Percentage of time in kernel space normalized by the number of CPU cores. - +Number of queries that have the DO bit set -type: scaled_float -format: percent +type: long -- -*`docker.cpu.kernel.ticks`*:: +*`coredns.stats.dns.request.type.count`*:: + -- -CPU ticks in kernel space. +Counter of queries per zone and type type: long -- -*`docker.cpu.system.pct`*:: +*`coredns.stats.type`*:: + -- -Percentage of total CPU time in the system. - +Holds the query type of the request -type: scaled_float -format: percent +type: keyword -- -*`docker.cpu.system.norm.pct`*:: +*`coredns.stats.dns.response.rcode.count`*:: + -- -Percentage of total CPU time in the system normalized by the number of CPU cores. - +Counter of responses per zone and rcode -type: scaled_float -format: percent +type: long -- -*`docker.cpu.system.ticks`*:: +*`coredns.stats.rcode`*:: + -- -CPU system ticks. +Holds the rcode of the response -type: long +type: keyword -- -*`docker.cpu.user.pct`*:: +*`coredns.stats.family`*:: + -- -Percentage of time in user space. - +The address family of the transport (1 = IP (IP version 4), 2 = IP6 (IP version 6)) -type: scaled_float -format: percent +type: keyword -- -*`docker.cpu.user.norm.pct`*:: +*`coredns.stats.dns.response.size.bytes.bucket.*`*:: + -- -Percentage of time in user space normalized by the number of CPU cores. - +Response Size histogram buckets -type: scaled_float -format: percent +type: object -- -*`docker.cpu.user.ticks`*:: +*`coredns.stats.dns.response.size.bytes.sum`*:: + -- -CPU ticks in user space. +Response Size histogram sum type: long -- -*`docker.cpu.total.pct`*:: +*`coredns.stats.dns.response.size.bytes.count`*:: + -- -Total CPU usage. - +Response Size histogram count -type: scaled_float -format: percent +type: long -- -*`docker.cpu.total.norm.pct`*:: +*`coredns.stats.server`*:: + -- -Total CPU usage normalized by the number of CPU cores. - +The server responsible for the request -type: scaled_float -format: percent +type: keyword -- -*`docker.cpu.core.*.pct`*:: +*`coredns.stats.zone`*:: + -- -Percentage of CPU time in this core. - +The zonename used for the request/response -type: object -format: percent +type: keyword -- -*`docker.cpu.core.*.norm.pct`*:: +*`coredns.stats.proto`*:: + -- -Percentage of CPU time in this core, normalized by the number of CPU cores. +The transport of the response ("udp" or "tcp") -type: object +type: keyword -format: percent +-- +*`coredns.stats.dns.cache.hits.count`*:: ++ -- +Cache hits count for the cache plugin -*`docker.cpu.core.*.ticks`*:: + +type: long + +-- + +*`coredns.stats.dns.cache.misses.count`*:: + -- -Number of CPU ticks in this core. +Cache misses count for the cache plugin -type: object +type: long -- +[[exported-fields-couchbase]] +== Couchbase fields + +Metrics collected from Couchbase servers. + + + [float] -=== diskio +=== couchbase -Disk I/O metrics. +`couchbase` contains the metrics that were scraped from Couchbase. [float] -=== read +=== bucket -Accumulated reads during the life of the container +Couchbase bucket metrics. -*`docker.diskio.read.ops`*:: +*`couchbase.bucket.name`*:: + -- -Number of reads during the life of the container +Name of the bucket. -type: long +type: keyword -- -*`docker.diskio.read.bytes`*:: +*`couchbase.bucket.type`*:: + -- -Bytes read during the life of the container +Type of the bucket. + + +type: keyword + +-- + +*`couchbase.bucket.data.used.bytes`*:: ++ +-- +Size of user data within buckets of the specified state that are resident in RAM. type: long @@ -5219,102 +4740,107 @@ format: bytes -- -*`docker.diskio.read.rate`*:: +*`couchbase.bucket.disk.fetches`*:: + -- -Number of current reads per second +Number of disk fetches. type: long -- -*`docker.diskio.reads`*:: +*`couchbase.bucket.disk.used.bytes`*:: + -- +Amount of disk used (bytes). -deprecated:[6.4] -Number of current reads per second +type: long +format: bytes -type: scaled_float +-- +*`couchbase.bucket.memory.used.bytes`*:: ++ -- +Amount of memory used by the bucket (bytes). -[float] -=== write -Accumulated writes during the life of the container +type: long +format: bytes +-- -*`docker.diskio.write.ops`*:: +*`couchbase.bucket.quota.ram.bytes`*:: + -- -Number of writes during the life of the container +Amount of RAM used by the bucket (bytes). type: long +format: bytes + -- -*`docker.diskio.write.bytes`*:: +*`couchbase.bucket.quota.use.pct`*:: + -- -Bytes written during the life of the container +Percentage of RAM used (for active objects) against the configured bucket size (%). -type: long +type: scaled_float -format: bytes +format: percent -- -*`docker.diskio.write.rate`*:: +*`couchbase.bucket.ops_per_sec`*:: + -- -Number of current writes per second +Number of operations per second. type: long -- -*`docker.diskio.writes`*:: +*`couchbase.bucket.item_count`*:: + -- - -deprecated:[6.4] - -Number of current writes per second +Number of items associated with the bucket. -type: scaled_float +type: long -- [float] -=== summary +=== cluster -Accumulated reads and writes during the life of the container +Couchbase cluster metrics. -*`docker.diskio.summary.ops`*:: +*`couchbase.cluster.hdd.free.bytes`*:: + -- -Number of I/O operations during the life of the container +Free hard drive space in the cluster (bytes). type: long +format: bytes + -- -*`docker.diskio.summary.bytes`*:: +*`couchbase.cluster.hdd.quota.total.bytes`*:: + -- -Bytes read and written during the life of the container +Hard drive quota total for the cluster (bytes). type: long @@ -5323,915 +4849,2609 @@ format: bytes -- -*`docker.diskio.summary.rate`*:: +*`couchbase.cluster.hdd.total.bytes`*:: + -- -Number of current operations per second +Total hard drive space available to the cluster (bytes). type: long +format: bytes + -- -*`docker.diskio.total`*:: +*`couchbase.cluster.hdd.used.value.bytes`*:: + -- +Hard drive space used by the cluster (bytes). -deprecated:[6.4] -Number of reads and writes per second +type: long +format: bytes -type: scaled_float +-- +*`couchbase.cluster.hdd.used.by_data.bytes`*:: ++ -- +Hard drive space used by the data in the cluster (bytes). -[float] -=== event -Docker event +type: long +format: bytes +-- -*`docker.event.status`*:: +*`couchbase.cluster.max_bucket_count`*:: + -- -Event status +Max bucket count setting. -type: keyword +type: long -- -*`docker.event.id`*:: +*`couchbase.cluster.quota.index_memory.mb`*:: + -- -Event id when available +Memory quota setting for the Index service (Mbyte). -type: keyword +type: long -- -*`docker.event.from`*:: +*`couchbase.cluster.quota.memory.mb`*:: + -- -Event source +Memory quota setting for the cluster (Mbyte). -type: keyword +type: long -- -*`docker.event.type`*:: +*`couchbase.cluster.ram.quota.total.value.bytes`*:: + -- -The type of object emitting the event +RAM quota total for the cluster (bytes). -type: keyword +type: long --- +format: bytes -*`docker.event.action`*:: -+ -- -The type of event - - -type: keyword +*`couchbase.cluster.ram.quota.total.per_node.bytes`*:: ++ -- +RAM quota used by the current node in the cluster (bytes). -[float] -=== actor -Actor +type: long +format: bytes +-- -*`docker.event.actor.id`*:: +*`couchbase.cluster.ram.quota.used.value.bytes`*:: + -- -The ID of the object emitting the event +RAM quota used by the cluster (bytes). -type: keyword +type: long + +format: bytes -- -*`docker.event.actor.attributes`*:: +*`couchbase.cluster.ram.quota.used.per_node.bytes`*:: + -- -Various key/value attributes of the object, depending on its type +Ram quota used by the current node in the cluster (bytes) -type: object +type: long + +format: bytes -- -[float] -=== healthcheck +*`couchbase.cluster.ram.total.bytes`*:: ++ +-- +Total RAM available to cluster (bytes). -Docker healthcheck metrics. -Healthcheck data will only be available from docker containers where the docker `HEALTHCHECK` instruction has been used to build the docker image. +type: long +format: bytes -*`docker.healthcheck.failingstreak`*:: +-- + +*`couchbase.cluster.ram.used.value.bytes`*:: + -- -concurent failed check +RAM used by the cluster (bytes). -type: integer +type: long + +format: bytes -- -*`docker.healthcheck.status`*:: +*`couchbase.cluster.ram.used.by_data.bytes`*:: + -- -Healthcheck status code +RAM used by the data in the cluster (bytes). -type: keyword +type: long + +format: bytes -- [float] -=== event +=== node -event fields. +Couchbase node metrics. -*`docker.healthcheck.event.end_date`*:: +*`couchbase.node.cmd_get`*:: + -- -Healthcheck end date +Number of get commands -type: date +type: long -- -*`docker.healthcheck.event.start_date`*:: +*`couchbase.node.couch.docs.disk_size.bytes`*:: + -- -Healthcheck start date +Amount of disk space used by Couch docs (bytes). -type: date +type: long + +format: bytes -- -*`docker.healthcheck.event.output`*:: +*`couchbase.node.couch.docs.data_size.bytes`*:: + -- -Healthcheck output +Data size of Couch docs associated with a node (bytes). -type: keyword +type: long + +format: bytes -- -*`docker.healthcheck.event.exit_code`*:: +*`couchbase.node.couch.spatial.data_size.bytes`*:: + -- -Healthcheck status code +Size of object data for spatial views (bytes). -type: integer +type: long -- -[float] -=== image +*`couchbase.node.couch.spatial.disk_size.bytes`*:: ++ +-- +Amount of disk space used by spatial views (bytes). -Docker image metrics. +type: long +-- -[float] -=== id +*`couchbase.node.couch.views.disk_size.bytes`*:: ++ +-- +Amount of disk space used by Couch views (bytes). -The image layers identifier. +type: long +-- -*`docker.image.id.current`*:: +*`couchbase.node.couch.views.data_size.bytes`*:: + -- -Unique image identifier given upon its creation. +Size of object data for Couch views (bytes). -type: keyword +type: long -- -*`docker.image.id.parent`*:: +*`couchbase.node.cpu_utilization_rate.pct`*:: + -- -Identifier of the image, if it exists, from which the current image directly descends. +The CPU utilization rate (%). -type: keyword +type: scaled_float -- -*`docker.image.created`*:: +*`couchbase.node.current_items.value`*:: + -- -Date and time when the image was created. +Number of current items. -type: date +type: long -- -[float] -=== size +*`couchbase.node.current_items.total`*:: ++ +-- +Total number of items associated with the node. -Image size layers. +type: long +-- -*`docker.image.size.virtual`*:: +*`couchbase.node.ep_bg_fetched`*:: + -- -Size of the image. +Number of disk fetches performed since the server was started. type: long -- -*`docker.image.size.regular`*:: +*`couchbase.node.get_hits`*:: + -- -Total size of the all cached images associated to the current image. +Number of get hits. type: long -- -*`docker.image.labels`*:: +*`couchbase.node.hostname`*:: + -- -Image labels. +The hostname of the node. -type: object +type: keyword -- -*`docker.image.tags`*:: +*`couchbase.node.mcd_memory.allocated.bytes`*:: + -- -Image tags. +Amount of memcached memory allocated (bytes). -type: keyword +type: long + +format: bytes -- -[float] -=== info +*`couchbase.node.mcd_memory.reserved.bytes`*:: ++ +-- +Amount of memcached memory reserved (bytes). -Info metrics based on https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/display-system-wide-information. +type: long +-- -[float] -=== containers +*`couchbase.node.memory.free.bytes`*:: ++ +-- +Amount of memory free for the node (bytes). -Overall container stats. +type: long +-- -*`docker.info.containers.paused`*:: +*`couchbase.node.memory.total.bytes`*:: + -- -Total number of paused containers. +Total memory available to the node (bytes). type: long -- -*`docker.info.containers.running`*:: +*`couchbase.node.memory.used.bytes`*:: + -- -Total number of running containers. +Memory used by the node (bytes). type: long -- -*`docker.info.containers.stopped`*:: +*`couchbase.node.ops`*:: + -- -Total number of stopped containers. +Number of operations performed on Couchbase. type: long -- -*`docker.info.containers.total`*:: +*`couchbase.node.swap.total.bytes`*:: + -- -Total number of existing containers. +Total swap size allocated (bytes). type: long -- -*`docker.info.id`*:: +*`couchbase.node.swap.used.bytes`*:: + -- -Unique Docker host identifier. +Amount of swap space used (bytes). -type: keyword +type: long -- -*`docker.info.images`*:: +*`couchbase.node.uptime.sec`*:: + -- -Total number of existing images. +Time during which the node was in operation (sec). + + +type: long + +-- + +*`couchbase.node.vb_replica_curr_items`*:: ++ +-- +Number of items/documents that are replicas. type: long -- +[[exported-fields-couchdb]] +== couchdb fields + +couchdb module + + + [float] -=== memory +=== couchdb -Memory metrics. -*`docker.memory.stats.*`*:: -+ --- -Raw memory stats from the cgroups memory.stat interface +[float] +=== server +Contains CouchDB server stats -type: object --- [float] -=== commit +=== httpd -Committed bytes on Windows +HTTP statistics -*`docker.memory.commit.total`*:: +*`couchdb.server.httpd.view_reads`*:: + -- -Total bytes +Number of view reads type: long -format: bytes - -- -*`docker.memory.commit.peak`*:: +*`couchdb.server.httpd.bulk_requests`*:: + -- -Peak committed bytes on Windows +Number of bulk requests type: long -format: bytes - -- -*`docker.memory.private_working_set.total`*:: +*`couchdb.server.httpd.clients_requesting_changes`*:: + -- -private working sets on Windows +Number of clients for continuous _changes type: long -format: bytes - -- -*`docker.memory.fail.count`*:: +*`couchdb.server.httpd.temporary_view_reads`*:: + -- -Fail counter. +Number of temporary view reads -type: scaled_float +type: long -- -*`docker.memory.limit`*:: +*`couchdb.server.httpd.requests`*:: + -- -Memory limit. +Number of HTTP requests type: long -format: bytes - -- [float] -=== rss +=== httpd_request_methods -RSS memory stats. +HTTP request methods -*`docker.memory.rss.total`*:: +*`couchdb.server.httpd_request_methods.COPY`*:: + -- -Total memory resident set size. +Number of HTTP COPY requests type: long -format: bytes - -- -*`docker.memory.rss.pct`*:: +*`couchdb.server.httpd_request_methods.HEAD`*:: + -- -Memory resident set size percentage. - +Number of HTTP HEAD requests -type: scaled_float -format: percent +type: long -- -[float] -=== usage +*`couchdb.server.httpd_request_methods.POST`*:: ++ +-- +Number of HTTP POST requests -Usage memory stats. +type: long +-- -*`docker.memory.usage.max`*:: +*`couchdb.server.httpd_request_methods.DELETE`*:: + -- -Max memory usage. +Number of HTTP DELETE requests type: long -format: bytes - -- -*`docker.memory.usage.pct`*:: +*`couchdb.server.httpd_request_methods.GET`*:: + -- -Memory usage percentage. - +Number of HTTP GET requests -type: scaled_float -format: percent +type: long -- -*`docker.memory.usage.total`*:: +*`couchdb.server.httpd_request_methods.PUT`*:: + -- -Total memory usage. +Number of HTTP PUT requests type: long -format: bytes - -- [float] -=== network +=== httpd_status_codes -Network metrics. +HTTP status codes statistics -*`docker.network.interface`*:: +*`couchdb.server.httpd_status_codes.200`*:: + -- -Network interface name. +Number of HTTP 200 OK responses -type: keyword +type: long -- -[float] -=== in - -Incoming network stats per second. - - - -*`docker.network.in.bytes`*:: +*`couchdb.server.httpd_status_codes.201`*:: + -- -Total number of incoming bytes. +Number of HTTP 201 Created responses type: long -format: bytes - -- -*`docker.network.in.dropped`*:: +*`couchdb.server.httpd_status_codes.202`*:: + -- -Total number of dropped incoming packets. +Number of HTTP 202 Accepted responses -type: scaled_float +type: long -- -*`docker.network.in.errors`*:: +*`couchdb.server.httpd_status_codes.301`*:: + -- -Total errors on incoming packets. +Number of HTTP 301 Moved Permanently responses type: long -- -*`docker.network.in.packets`*:: +*`couchdb.server.httpd_status_codes.304`*:: + -- -Total number of incoming packets. +Number of HTTP 304 Not Modified responses type: long -- -[float] -=== out +*`couchdb.server.httpd_status_codes.400`*:: ++ +-- +Number of HTTP 400 Bad Request responses -Outgoing network stats per second. +type: long +-- -*`docker.network.out.bytes`*:: +*`couchdb.server.httpd_status_codes.401`*:: + -- -Total number of outgoing bytes. +Number of HTTP 401 Unauthorized responses type: long -format: bytes - -- -*`docker.network.out.dropped`*:: +*`couchdb.server.httpd_status_codes.403`*:: + -- -Total number of dropped outgoing packets. +Number of HTTP 403 Forbidden responses -type: scaled_float +type: long -- -*`docker.network.out.errors`*:: +*`couchdb.server.httpd_status_codes.404`*:: + -- -Total errors on outgoing packets. +Number of HTTP 404 Not Found responses type: long -- -*`docker.network.out.packets`*:: +*`couchdb.server.httpd_status_codes.405`*:: + -- -Total number of outgoing packets. +Number of HTTP 405 Method Not Allowed responses type: long -- -[float] -=== inbound +*`couchdb.server.httpd_status_codes.409`*:: ++ +-- +Number of HTTP 409 Conflict responses -Incoming network stats since the container started. +type: long +-- -*`docker.network.inbound.bytes`*:: +*`couchdb.server.httpd_status_codes.412`*:: + -- -Total number of incoming bytes. +Number of HTTP 412 Precondition Failed responses type: long -format: bytes - -- -*`docker.network.inbound.dropped`*:: +*`couchdb.server.httpd_status_codes.500`*:: + -- -Total number of dropped incoming packets. +Number of HTTP 500 Internal Server Error responses type: long -- -*`docker.network.inbound.errors`*:: +[float] +=== couchdb + +couchdb statistics + + + +*`couchdb.server.couchdb.database_writes`*:: + -- -Total errors on incoming packets. +Number of times a database was changed type: long -- -*`docker.network.inbound.packets`*:: +*`couchdb.server.couchdb.open_databases`*:: + -- -Total number of incoming packets. +Number of open databases type: long -- -[float] -=== outbound +*`couchdb.server.couchdb.auth_cache_misses`*:: ++ +-- +Number of authentication cache misses -Outgoing network stats since the container started. +type: long +-- -*`docker.network.outbound.bytes`*:: +*`couchdb.server.couchdb.request_time`*:: + -- -Total number of outgoing bytes. +Length of a request inside CouchDB without MochiWeb type: long -format: bytes - -- -*`docker.network.outbound.dropped`*:: +*`couchdb.server.couchdb.database_reads`*:: + -- -Total number of dropped outgoing packets. +Number of times a document was read from a database type: long -- -*`docker.network.outbound.errors`*:: +*`couchdb.server.couchdb.auth_cache_hits`*:: + -- -Total errors on outgoing packets. +Number of authentication cache hits type: long -- -*`docker.network.outbound.packets`*:: +*`couchdb.server.couchdb.open_os_files`*:: + -- -Total number of outgoing packets. +Number of file descriptors CouchDB has open type: long -- -[[exported-fields-dropwizard]] -== Dropwizard fields - -Stats collected from Dropwizard. - - +[[exported-fields-docker-processor]] +== Docker fields -[float] -=== dropwizard +Docker stats collected from Docker. -[[exported-fields-ecs]] -== ECS fields +*`docker.container.id`*:: ++ +-- +type: alias -ECS Fields. +alias to: container.id +-- -*`@timestamp`*:: +*`docker.container.image`*:: + -- -Date/time when the event originated. -This is the date/time extracted from the event, typically representing when the event was generated by the source. -If the event source has no original timestamp, this value is typically populated by the first time the event was received by the pipeline. -Required field for all events. - -type: date - -example: 2016-05-23T08:05:34.853Z +type: alias -required: True +alias to: container.image.name -- -*`labels`*:: +*`docker.container.name`*:: + -- -Custom key/value pairs. -Can be used to add meta information to events. Should not contain nested objects. All values are stored as keyword. -Example: `docker` and `k8s` labels. - -type: object +type: alias -example: {'application': 'foo-bar', 'env': 'production'} +alias to: container.name -- -*`message`*:: +*`docker.container.labels`*:: + -- -For log events the message field contains the log message, optimized for viewing in a log viewer. -For structured logs without an original message field, other fields can be concatenated to form a human-readable summary of the event. -If multiple messages exist, they can be combined into one message. +Image labels. -type: text -example: Hello World +type: object -- -*`tags`*:: -+ --- -List of keywords used to tag each event. +[[exported-fields-docker]] +== Docker fields -type: keyword +Docker stats collected from Docker. -example: ["production", "env2"] --- [float] -=== agent +=== docker -The agent fields contain the data about the software entity, if any, that collects, detects, or observes events on a host, or takes measurements on a host. -Examples include Beats. Agents may also run on observers. ECS agent.* fields shall be populated with details of the agent running on the host or observer where the event happened or the measurement was taken. +Information and statistics about docker's running containers. -*`agent.ephemeral_id`*:: -+ --- -Ephemeral identifier of this agent (if one exists). -This id normally changes across restarts, but `agent.id` does not. -type: keyword +[float] +=== container -example: 8a4f500f +Docker container metrics. --- -*`agent.id`*:: + +*`docker.container.command`*:: + -- -Unique identifier of this agent (if one exists). -Example: For Beats this would be beat.id. +Command that was executed in the Docker container. -type: keyword -example: 8a4f500d +type: keyword -- -*`agent.name`*:: +*`docker.container.created`*:: + -- -Custom name of the agent. -This is a name that can be given to an agent. This can be helpful if for example two Filebeat instances are running on the same host but a human readable separation is needed on which Filebeat instance data is coming from. -If no name is given, the name is often left empty. +Date when the container was created. -type: keyword -example: foo +type: date -- -*`agent.type`*:: +*`docker.container.status`*:: + -- -Type of the agent. -The agent type stays always the same and should be given by the agent used. In case of Filebeat the agent would always be Filebeat also if two Filebeat instances are run on the same machine. +Container status. -type: keyword -example: filebeat +type: keyword -- -*`agent.version`*:: +*`docker.container.ip_addresses`*:: + -- -Version of the agent. +Container IP addresses. -type: keyword -example: 6.0.0-rc2 +type: ip -- [float] -=== as +=== size -An autonomous system (AS) is a collection of connected Internet Protocol (IP) routing prefixes under the control of one or more network operators on behalf of a single administrative entity or domain that presents a common, clearly defined routing policy to the internet. +Container size metrics. -*`as.number`*:: + +*`docker.container.size.root_fs`*:: + -- -Unique number allocated to the autonomous system. The autonomous system number (ASN) uniquely identifies each network on the Internet. +Total size of all the files in the container. -type: long -example: 15169 +type: long -- -*`as.organization.name`*:: +*`docker.container.size.rw`*:: + -- -Organization name. +Size of the files that have been created or changed since creation. -type: keyword -example: Google LLC +type: long -- -*`as.organization.name.text`*:: +*`docker.container.tags`*:: + -- -type: text +Image tags. --- + +type: keyword + +-- + +[float] +=== cpu + +Runtime CPU metrics. + + + +*`docker.cpu.kernel.pct`*:: ++ +-- +Percentage of time in kernel space. + + +type: scaled_float + +format: percent + +-- + +*`docker.cpu.kernel.norm.pct`*:: ++ +-- +Percentage of time in kernel space normalized by the number of CPU cores. + + +type: scaled_float + +format: percent + +-- + +*`docker.cpu.kernel.ticks`*:: ++ +-- +CPU ticks in kernel space. + + +type: long + +-- + +*`docker.cpu.system.pct`*:: ++ +-- +Percentage of total CPU time in the system. + + +type: scaled_float + +format: percent + +-- + +*`docker.cpu.system.norm.pct`*:: ++ +-- +Percentage of total CPU time in the system normalized by the number of CPU cores. + + +type: scaled_float + +format: percent + +-- + +*`docker.cpu.system.ticks`*:: ++ +-- +CPU system ticks. + + +type: long + +-- + +*`docker.cpu.user.pct`*:: ++ +-- +Percentage of time in user space. + + +type: scaled_float + +format: percent + +-- + +*`docker.cpu.user.norm.pct`*:: ++ +-- +Percentage of time in user space normalized by the number of CPU cores. + + +type: scaled_float + +format: percent + +-- + +*`docker.cpu.user.ticks`*:: ++ +-- +CPU ticks in user space. + + +type: long + +-- + +*`docker.cpu.total.pct`*:: ++ +-- +Total CPU usage. + + +type: scaled_float + +format: percent + +-- + +*`docker.cpu.total.norm.pct`*:: ++ +-- +Total CPU usage normalized by the number of CPU cores. + + +type: scaled_float + +format: percent + +-- + +*`docker.cpu.core.*.pct`*:: ++ +-- +Percentage of CPU time in this core. + + +type: object + +format: percent + +-- + +*`docker.cpu.core.*.norm.pct`*:: ++ +-- +Percentage of CPU time in this core, normalized by the number of CPU cores. + + +type: object + +format: percent + +-- + +*`docker.cpu.core.*.ticks`*:: ++ +-- +Number of CPU ticks in this core. + + +type: object + +-- + +[float] +=== diskio + +Disk I/O metrics. + + + +[float] +=== read + +Accumulated reads during the life of the container + + + +*`docker.diskio.read.ops`*:: ++ +-- +Number of reads during the life of the container + + +type: long + +-- + +*`docker.diskio.read.bytes`*:: ++ +-- +Bytes read during the life of the container + + +type: long + +format: bytes + +-- + +*`docker.diskio.read.rate`*:: ++ +-- +Number of current reads per second + + +type: long + +-- + +*`docker.diskio.reads`*:: ++ +-- + +deprecated:[6.4] + +Number of current reads per second + + +type: scaled_float + +-- + +[float] +=== write + +Accumulated writes during the life of the container + + + +*`docker.diskio.write.ops`*:: ++ +-- +Number of writes during the life of the container + + +type: long + +-- + +*`docker.diskio.write.bytes`*:: ++ +-- +Bytes written during the life of the container + + +type: long + +format: bytes + +-- + +*`docker.diskio.write.rate`*:: ++ +-- +Number of current writes per second + + +type: long + +-- + +*`docker.diskio.writes`*:: ++ +-- + +deprecated:[6.4] + +Number of current writes per second + + +type: scaled_float + +-- + +[float] +=== summary + +Accumulated reads and writes during the life of the container + + + +*`docker.diskio.summary.ops`*:: ++ +-- +Number of I/O operations during the life of the container + + +type: long + +-- + +*`docker.diskio.summary.bytes`*:: ++ +-- +Bytes read and written during the life of the container + + +type: long + +format: bytes + +-- + +*`docker.diskio.summary.rate`*:: ++ +-- +Number of current operations per second + + +type: long + +-- + +*`docker.diskio.total`*:: ++ +-- + +deprecated:[6.4] + +Number of reads and writes per second + + +type: scaled_float + +-- + +[float] +=== event + +Docker event + + + +*`docker.event.status`*:: ++ +-- +Event status + + +type: keyword + +-- + +*`docker.event.id`*:: ++ +-- +Event id when available + + +type: keyword + +-- + +*`docker.event.from`*:: ++ +-- +Event source + + +type: keyword + +-- + +*`docker.event.type`*:: ++ +-- +The type of object emitting the event + + +type: keyword + +-- + +*`docker.event.action`*:: ++ +-- +The type of event + + +type: keyword + +-- + +[float] +=== actor + +Actor + + + +*`docker.event.actor.id`*:: ++ +-- +The ID of the object emitting the event + + +type: keyword + +-- + +*`docker.event.actor.attributes`*:: ++ +-- +Various key/value attributes of the object, depending on its type + + +type: object + +-- + +[float] +=== healthcheck + +Docker healthcheck metrics. +Healthcheck data will only be available from docker containers where the docker `HEALTHCHECK` instruction has been used to build the docker image. + + + +*`docker.healthcheck.failingstreak`*:: ++ +-- +concurent failed check + + +type: integer + +-- + +*`docker.healthcheck.status`*:: ++ +-- +Healthcheck status code + + +type: keyword + +-- + +[float] +=== event + +event fields. + + + +*`docker.healthcheck.event.end_date`*:: ++ +-- +Healthcheck end date + + +type: date + +-- + +*`docker.healthcheck.event.start_date`*:: ++ +-- +Healthcheck start date + + +type: date + +-- + +*`docker.healthcheck.event.output`*:: ++ +-- +Healthcheck output + + +type: keyword + +-- + +*`docker.healthcheck.event.exit_code`*:: ++ +-- +Healthcheck status code + + +type: integer + +-- + +[float] +=== image + +Docker image metrics. + + + +[float] +=== id + +The image layers identifier. + + + +*`docker.image.id.current`*:: ++ +-- +Unique image identifier given upon its creation. + + +type: keyword + +-- + +*`docker.image.id.parent`*:: ++ +-- +Identifier of the image, if it exists, from which the current image directly descends. + + +type: keyword + +-- + +*`docker.image.created`*:: ++ +-- +Date and time when the image was created. + + +type: date + +-- + +[float] +=== size + +Image size layers. + + + +*`docker.image.size.virtual`*:: ++ +-- +Size of the image. + + +type: long + +-- + +*`docker.image.size.regular`*:: ++ +-- +Total size of the all cached images associated to the current image. + + +type: long + +-- + +*`docker.image.labels`*:: ++ +-- +Image labels. + + +type: object + +-- + +*`docker.image.tags`*:: ++ +-- +Image tags. + + +type: keyword + +-- + +[float] +=== info + +Info metrics based on https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/display-system-wide-information. + + + +[float] +=== containers + +Overall container stats. + + + +*`docker.info.containers.paused`*:: ++ +-- +Total number of paused containers. + + +type: long + +-- + +*`docker.info.containers.running`*:: ++ +-- +Total number of running containers. + + +type: long + +-- + +*`docker.info.containers.stopped`*:: ++ +-- +Total number of stopped containers. + + +type: long + +-- + +*`docker.info.containers.total`*:: ++ +-- +Total number of existing containers. + + +type: long + +-- + +*`docker.info.id`*:: ++ +-- +Unique Docker host identifier. + + +type: keyword + +-- + +*`docker.info.images`*:: ++ +-- +Total number of existing images. + + +type: long + +-- + +[float] +=== memory + +Memory metrics. + + + +*`docker.memory.stats.*`*:: ++ +-- +Raw memory stats from the cgroups memory.stat interface + + +type: object + +-- + +[float] +=== commit + +Committed bytes on Windows + + + +*`docker.memory.commit.total`*:: ++ +-- +Total bytes + + +type: long + +format: bytes + +-- + +*`docker.memory.commit.peak`*:: ++ +-- +Peak committed bytes on Windows + + +type: long + +format: bytes + +-- + +*`docker.memory.private_working_set.total`*:: ++ +-- +private working sets on Windows + + +type: long + +format: bytes + +-- + +*`docker.memory.fail.count`*:: ++ +-- +Fail counter. + + +type: scaled_float + +-- + +*`docker.memory.limit`*:: ++ +-- +Memory limit. + + +type: long + +format: bytes + +-- + +[float] +=== rss + +RSS memory stats. + + + +*`docker.memory.rss.total`*:: ++ +-- +Total memory resident set size. + + +type: long + +format: bytes + +-- + +*`docker.memory.rss.pct`*:: ++ +-- +Memory resident set size percentage. + + +type: scaled_float + +format: percent + +-- + +[float] +=== usage + +Usage memory stats. + + + +*`docker.memory.usage.max`*:: ++ +-- +Max memory usage. + + +type: long + +format: bytes + +-- + +*`docker.memory.usage.pct`*:: ++ +-- +Memory usage percentage. + + +type: scaled_float + +format: percent + +-- + +*`docker.memory.usage.total`*:: ++ +-- +Total memory usage. + + +type: long + +format: bytes + +-- + +[float] +=== network + +Network metrics. + + + +*`docker.network.interface`*:: ++ +-- +Network interface name. + + +type: keyword + +-- + +[float] +=== in + +Incoming network stats per second. + + + +*`docker.network.in.bytes`*:: ++ +-- +Total number of incoming bytes. + + +type: long + +format: bytes + +-- + +*`docker.network.in.dropped`*:: ++ +-- +Total number of dropped incoming packets. + + +type: scaled_float + +-- + +*`docker.network.in.errors`*:: ++ +-- +Total errors on incoming packets. + + +type: long + +-- + +*`docker.network.in.packets`*:: ++ +-- +Total number of incoming packets. + + +type: long + +-- + +[float] +=== out + +Outgoing network stats per second. + + + +*`docker.network.out.bytes`*:: ++ +-- +Total number of outgoing bytes. + + +type: long + +format: bytes + +-- + +*`docker.network.out.dropped`*:: ++ +-- +Total number of dropped outgoing packets. + + +type: scaled_float + +-- + +*`docker.network.out.errors`*:: ++ +-- +Total errors on outgoing packets. + + +type: long + +-- + +*`docker.network.out.packets`*:: ++ +-- +Total number of outgoing packets. + + +type: long + +-- + +[float] +=== inbound + +Incoming network stats since the container started. + + + +*`docker.network.inbound.bytes`*:: ++ +-- +Total number of incoming bytes. + + +type: long + +format: bytes + +-- + +*`docker.network.inbound.dropped`*:: ++ +-- +Total number of dropped incoming packets. + + +type: long + +-- + +*`docker.network.inbound.errors`*:: ++ +-- +Total errors on incoming packets. + + +type: long + +-- + +*`docker.network.inbound.packets`*:: ++ +-- +Total number of incoming packets. + + +type: long + +-- + +[float] +=== outbound + +Outgoing network stats since the container started. + + + +*`docker.network.outbound.bytes`*:: ++ +-- +Total number of outgoing bytes. + + +type: long + +format: bytes + +-- + +*`docker.network.outbound.dropped`*:: ++ +-- +Total number of dropped outgoing packets. + + +type: long + +-- + +*`docker.network.outbound.errors`*:: ++ +-- +Total errors on outgoing packets. + + +type: long + +-- + +*`docker.network.outbound.packets`*:: ++ +-- +Total number of outgoing packets. + + +type: long + +-- + +[[exported-fields-dropwizard]] +== Dropwizard fields + +Stats collected from Dropwizard. + + + +[float] +=== dropwizard + + + + +[[exported-fields-ecs]] +== ECS fields + +ECS Fields. + + +*`@timestamp`*:: ++ +-- +Date/time when the event originated. +This is the date/time extracted from the event, typically representing when the event was generated by the source. +If the event source has no original timestamp, this value is typically populated by the first time the event was received by the pipeline. +Required field for all events. + +type: date + +example: 2016-05-23T08:05:34.853Z + +required: True + +-- + +*`labels`*:: ++ +-- +Custom key/value pairs. +Can be used to add meta information to events. Should not contain nested objects. All values are stored as keyword. +Example: `docker` and `k8s` labels. + +type: object + +example: {'application': 'foo-bar', 'env': 'production'} + +-- + +*`message`*:: ++ +-- +For log events the message field contains the log message, optimized for viewing in a log viewer. +For structured logs without an original message field, other fields can be concatenated to form a human-readable summary of the event. +If multiple messages exist, they can be combined into one message. + +type: text + +example: Hello World + +-- + +*`tags`*:: ++ +-- +List of keywords used to tag each event. + +type: keyword + +example: ["production", "env2"] + +-- + +[float] +=== agent + +The agent fields contain the data about the software entity, if any, that collects, detects, or observes events on a host, or takes measurements on a host. +Examples include Beats. Agents may also run on observers. ECS agent.* fields shall be populated with details of the agent running on the host or observer where the event happened or the measurement was taken. + + +*`agent.ephemeral_id`*:: ++ +-- +Ephemeral identifier of this agent (if one exists). +This id normally changes across restarts, but `agent.id` does not. + +type: keyword + +example: 8a4f500f + +-- + +*`agent.id`*:: ++ +-- +Unique identifier of this agent (if one exists). +Example: For Beats this would be beat.id. + +type: keyword + +example: 8a4f500d + +-- + +*`agent.name`*:: ++ +-- +Custom name of the agent. +This is a name that can be given to an agent. This can be helpful if for example two Filebeat instances are running on the same host but a human readable separation is needed on which Filebeat instance data is coming from. +If no name is given, the name is often left empty. + +type: keyword + +example: foo + +-- + +*`agent.type`*:: ++ +-- +Type of the agent. +The agent type stays always the same and should be given by the agent used. In case of Filebeat the agent would always be Filebeat also if two Filebeat instances are run on the same machine. + +type: keyword + +example: filebeat + +-- + +*`agent.version`*:: ++ +-- +Version of the agent. + +type: keyword + +example: 6.0.0-rc2 + +-- + +[float] +=== as + +An autonomous system (AS) is a collection of connected Internet Protocol (IP) routing prefixes under the control of one or more network operators on behalf of a single administrative entity or domain that presents a common, clearly defined routing policy to the internet. + + +*`as.number`*:: ++ +-- +Unique number allocated to the autonomous system. The autonomous system number (ASN) uniquely identifies each network on the Internet. + +type: long + +example: 15169 + +-- + +*`as.organization.name`*:: ++ +-- +Organization name. + +type: keyword + +example: Google LLC + +-- + +*`as.organization.name.text`*:: ++ +-- +type: text + +-- + +[float] +=== client + +A client is defined as the initiator of a network connection for events regarding sessions, connections, or bidirectional flow records. +For TCP events, the client is the initiator of the TCP connection that sends the SYN packet(s). For other protocols, the client is generally the initiator or requestor in the network transaction. Some systems use the term "originator" to refer the client in TCP connections. The client fields describe details about the system acting as the client in the network event. Client fields are usually populated in conjunction with server fields. Client fields are generally not populated for packet-level events. +Client / server representations can add semantic context to an exchange, which is helpful to visualize the data in certain situations. If your context falls in that category, you should still ensure that source and destination are filled appropriately. + + +*`client.address`*:: ++ +-- +Some event client addresses are defined ambiguously. The event will sometimes list an IP, a domain or a unix socket. You should always store the raw address in the `.address` field. +Then it should be duplicated to `.ip` or `.domain`, depending on which one it is. + +type: keyword + +-- + +*`client.as.number`*:: ++ +-- +Unique number allocated to the autonomous system. The autonomous system number (ASN) uniquely identifies each network on the Internet. + +type: long + +example: 15169 + +-- + +*`client.as.organization.name`*:: ++ +-- +Organization name. + +type: keyword + +example: Google LLC + +-- + +*`client.as.organization.name.text`*:: ++ +-- +type: text + +-- + +*`client.bytes`*:: ++ +-- +Bytes sent from the client to the server. + +type: long + +example: 184 + +format: bytes + +-- + +*`client.domain`*:: ++ +-- +Client domain. + +type: keyword + +-- + +*`client.geo.city_name`*:: ++ +-- +City name. + +type: keyword + +example: Montreal + +-- + +*`client.geo.continent_name`*:: ++ +-- +Name of the continent. + +type: keyword + +example: North America + +-- + +*`client.geo.country_iso_code`*:: ++ +-- +Country ISO code. + +type: keyword + +example: CA + +-- + +*`client.geo.country_name`*:: ++ +-- +Country name. + +type: keyword + +example: Canada + +-- + +*`client.geo.location`*:: ++ +-- +Longitude and latitude. + +type: geo_point + +example: { "lon": -73.614830, "lat": 45.505918 } + +-- + +*`client.geo.name`*:: ++ +-- +User-defined description of a location, at the level of granularity they care about. +Could be the name of their data centers, the floor number, if this describes a local physical entity, city names. +Not typically used in automated geolocation. + +type: keyword + +example: boston-dc + +-- + +*`client.geo.region_iso_code`*:: ++ +-- +Region ISO code. + +type: keyword + +example: CA-QC + +-- + +*`client.geo.region_name`*:: ++ +-- +Region name. + +type: keyword + +example: Quebec + +-- + +*`client.ip`*:: ++ +-- +IP address of the client. +Can be one or multiple IPv4 or IPv6 addresses. + +type: ip + +-- + +*`client.mac`*:: ++ +-- +MAC address of the client. + +type: keyword + +-- + +*`client.nat.ip`*:: ++ +-- +Translated IP of source based NAT sessions (e.g. internal client to internet). +Typically connections traversing load balancers, firewalls, or routers. + +type: ip + +-- + +*`client.nat.port`*:: ++ +-- +Translated port of source based NAT sessions (e.g. internal client to internet). +Typically connections traversing load balancers, firewalls, or routers. + +type: long + +format: string + +-- + +*`client.packets`*:: ++ +-- +Packets sent from the client to the server. + +type: long + +example: 12 + +-- + +*`client.port`*:: ++ +-- +Port of the client. + +type: long + +format: string + +-- + +*`client.registered_domain`*:: ++ +-- +The highest registered client domain, stripped of the subdomain. +For example, the registered domain for "foo.google.com" is "google.com". +This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last two labels will not work well for TLDs such as "co.uk". + +type: keyword + +example: google.com + +-- + +*`client.top_level_domain`*:: ++ +-- +The effective top level domain (eTLD), also known as the domain suffix, is the last part of the domain name. For example, the top level domain for google.com is "com". +This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last label will not work well for effective TLDs such as "co.uk". + +type: keyword + +example: co.uk + +-- + +*`client.user.domain`*:: ++ +-- +Name of the directory the user is a member of. +For example, an LDAP or Active Directory domain name. + +type: keyword + +-- + +*`client.user.email`*:: ++ +-- +User email address. + +type: keyword + +-- + +*`client.user.full_name`*:: ++ +-- +User's full name, if available. + +type: keyword + +example: Albert Einstein + +-- + +*`client.user.full_name.text`*:: ++ +-- +type: text + +-- + +*`client.user.group.domain`*:: ++ +-- +Name of the directory the group is a member of. +For example, an LDAP or Active Directory domain name. + +type: keyword + +-- + +*`client.user.group.id`*:: ++ +-- +Unique identifier for the group on the system/platform. + +type: keyword + +-- + +*`client.user.group.name`*:: ++ +-- +Name of the group. + +type: keyword + +-- + +*`client.user.hash`*:: ++ +-- +Unique user hash to correlate information for a user in anonymized form. +Useful if `user.id` or `user.name` contain confidential information and cannot be used. + +type: keyword + +-- + +*`client.user.id`*:: ++ +-- +One or multiple unique identifiers of the user. + +type: keyword + +-- + +*`client.user.name`*:: ++ +-- +Short name or login of the user. + +type: keyword + +example: albert + +-- + +*`client.user.name.text`*:: ++ +-- +type: text + +-- + +[float] +=== cloud + +Fields related to the cloud or infrastructure the events are coming from. + + +*`cloud.account.id`*:: ++ +-- +The cloud account or organization id used to identify different entities in a multi-tenant environment. +Examples: AWS account id, Google Cloud ORG Id, or other unique identifier. + +type: keyword + +example: 666777888999 + +-- + +*`cloud.availability_zone`*:: ++ +-- +Availability zone in which this host is running. + +type: keyword + +example: us-east-1c + +-- + +*`cloud.instance.id`*:: ++ +-- +Instance ID of the host machine. + +type: keyword + +example: i-1234567890abcdef0 + +-- + +*`cloud.instance.name`*:: ++ +-- +Instance name of the host machine. + +type: keyword + +-- + +*`cloud.machine.type`*:: ++ +-- +Machine type of the host machine. + +type: keyword + +example: t2.medium + +-- + +*`cloud.provider`*:: ++ +-- +Name of the cloud provider. Example values are aws, azure, gcp, or digitalocean. + +type: keyword + +example: aws + +-- + +*`cloud.region`*:: ++ +-- +Region in which this host is running. + +type: keyword + +example: us-east-1 + +-- [float] -=== client +=== container -A client is defined as the initiator of a network connection for events regarding sessions, connections, or bidirectional flow records. -For TCP events, the client is the initiator of the TCP connection that sends the SYN packet(s). For other protocols, the client is generally the initiator or requestor in the network transaction. Some systems use the term "originator" to refer the client in TCP connections. The client fields describe details about the system acting as the client in the network event. Client fields are usually populated in conjunction with server fields. Client fields are generally not populated for packet-level events. -Client / server representations can add semantic context to an exchange, which is helpful to visualize the data in certain situations. If your context falls in that category, you should still ensure that source and destination are filled appropriately. +Container fields are used for meta information about the specific container that is the source of information. +These fields help correlate data based containers from any runtime. -*`client.address`*:: +*`container.id`*:: + -- -Some event client addresses are defined ambiguously. The event will sometimes list an IP, a domain or a unix socket. You should always store the raw address in the `.address` field. +Unique container id. + +type: keyword + +-- + +*`container.image.name`*:: ++ +-- +Name of the image the container was built on. + +type: keyword + +-- + +*`container.image.tag`*:: ++ +-- +Container image tag. + +type: keyword + +-- + +*`container.labels`*:: ++ +-- +Image labels. + +type: object + +-- + +*`container.name`*:: ++ +-- +Container name. + +type: keyword + +-- + +*`container.runtime`*:: ++ +-- +Runtime managing this container. + +type: keyword + +example: docker + +-- + +[float] +=== destination + +Destination fields describe details about the destination of a packet/event. +Destination fields are usually populated in conjunction with source fields. + + +*`destination.address`*:: ++ +-- +Some event destination addresses are defined ambiguously. The event will sometimes list an IP, a domain or a unix socket. You should always store the raw address in the `.address` field. Then it should be duplicated to `.ip` or `.domain`, depending on which one it is. type: keyword -- -*`client.as.number`*:: +*`destination.as.number`*:: + -- Unique number allocated to the autonomous system. The autonomous system number (ASN) uniquely identifies each network on the Internet. @@ -6242,7 +7462,7 @@ example: 15169 -- -*`client.as.organization.name`*:: +*`destination.as.organization.name`*:: + -- Organization name. @@ -6253,17 +7473,17 @@ example: Google LLC -- -*`client.as.organization.name.text`*:: +*`destination.as.organization.name.text`*:: + -- type: text -- -*`client.bytes`*:: +*`destination.bytes`*:: + -- -Bytes sent from the client to the server. +Bytes sent from the destination to the source. type: long @@ -6273,16 +7493,16 @@ format: bytes -- -*`client.domain`*:: +*`destination.domain`*:: + -- -Client domain. +Destination domain. type: keyword -- -*`client.geo.city_name`*:: +*`destination.geo.city_name`*:: + -- City name. @@ -6293,7 +7513,7 @@ example: Montreal -- -*`client.geo.continent_name`*:: +*`destination.geo.continent_name`*:: + -- Name of the continent. @@ -6304,7 +7524,7 @@ example: North America -- -*`client.geo.country_iso_code`*:: +*`destination.geo.country_iso_code`*:: + -- Country ISO code. @@ -6315,7 +7535,7 @@ example: CA -- -*`client.geo.country_name`*:: +*`destination.geo.country_name`*:: + -- Country name. @@ -6326,7 +7546,7 @@ example: Canada -- -*`client.geo.location`*:: +*`destination.geo.location`*:: + -- Longitude and latitude. @@ -6337,7 +7557,7 @@ example: { "lon": -73.614830, "lat": 45.505918 } -- -*`client.geo.name`*:: +*`destination.geo.name`*:: + -- User-defined description of a location, at the level of granularity they care about. @@ -6350,7 +7570,7 @@ example: boston-dc -- -*`client.geo.region_iso_code`*:: +*`destination.geo.region_iso_code`*:: + -- Region ISO code. @@ -6361,7 +7581,7 @@ example: CA-QC -- -*`client.geo.region_name`*:: +*`destination.geo.region_name`*:: + -- Region name. @@ -6372,40 +7592,40 @@ example: Quebec -- -*`client.ip`*:: +*`destination.ip`*:: + -- -IP address of the client. +IP address of the destination. Can be one or multiple IPv4 or IPv6 addresses. type: ip -- -*`client.mac`*:: +*`destination.mac`*:: + -- -MAC address of the client. +MAC address of the destination. type: keyword -- -*`client.nat.ip`*:: +*`destination.nat.ip`*:: + -- -Translated IP of source based NAT sessions (e.g. internal client to internet). -Typically connections traversing load balancers, firewalls, or routers. +Translated ip of destination based NAT sessions (e.g. internet to private DMZ) +Typically used with load balancers, firewalls, or routers. type: ip -- -*`client.nat.port`*:: +*`destination.nat.port`*:: + -- -Translated port of source based NAT sessions (e.g. internal client to internet). -Typically connections traversing load balancers, firewalls, or routers. +Port the source session is translated to by NAT Device. +Typically used with load balancers, firewalls, or routers. type: long @@ -6413,10 +7633,10 @@ format: string -- -*`client.packets`*:: +*`destination.packets`*:: + -- -Packets sent from the client to the server. +Packets sent from the destination to the source. type: long @@ -6424,10 +7644,10 @@ example: 12 -- -*`client.port`*:: +*`destination.port`*:: + -- -Port of the client. +Port of the destination. type: long @@ -6435,10 +7655,10 @@ format: string -- -*`client.registered_domain`*:: +*`destination.registered_domain`*:: + -- -The highest registered client domain, stripped of the subdomain. +The highest registered destination domain, stripped of the subdomain. For example, the registered domain for "foo.google.com" is "google.com". This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last two labels will not work well for TLDs such as "co.uk". @@ -6448,7 +7668,7 @@ example: google.com -- -*`client.top_level_domain`*:: +*`destination.top_level_domain`*:: + -- The effective top level domain (eTLD), also known as the domain suffix, is the last part of the domain name. For example, the top level domain for google.com is "com". @@ -6460,7 +7680,7 @@ example: co.uk -- -*`client.user.domain`*:: +*`destination.user.domain`*:: + -- Name of the directory the user is a member of. @@ -6470,7 +7690,7 @@ type: keyword -- -*`client.user.email`*:: +*`destination.user.email`*:: + -- User email address. @@ -6479,7 +7699,7 @@ type: keyword -- -*`client.user.full_name`*:: +*`destination.user.full_name`*:: + -- User's full name, if available. @@ -6490,14 +7710,14 @@ example: Albert Einstein -- -*`client.user.full_name.text`*:: +*`destination.user.full_name.text`*:: + -- type: text -- -*`client.user.group.domain`*:: +*`destination.user.group.domain`*:: + -- Name of the directory the group is a member of. @@ -6507,1492 +7727,1377 @@ type: keyword -- -*`client.user.group.id`*:: +*`destination.user.group.id`*:: + -- Unique identifier for the group on the system/platform. -type: keyword - --- - -*`client.user.group.name`*:: -+ --- -Name of the group. - -type: keyword - --- - -*`client.user.hash`*:: -+ --- -Unique user hash to correlate information for a user in anonymized form. -Useful if `user.id` or `user.name` contain confidential information and cannot be used. - -type: keyword - --- - -*`client.user.id`*:: -+ --- -One or multiple unique identifiers of the user. - -type: keyword - --- - -*`client.user.name`*:: -+ --- -Short name or login of the user. - -type: keyword - -example: albert - --- - -*`client.user.name.text`*:: -+ --- -type: text - --- - -[float] -=== cloud - -Fields related to the cloud or infrastructure the events are coming from. - - -*`cloud.account.id`*:: -+ --- -The cloud account or organization id used to identify different entities in a multi-tenant environment. -Examples: AWS account id, Google Cloud ORG Id, or other unique identifier. - -type: keyword - -example: 666777888999 - --- - -*`cloud.availability_zone`*:: -+ --- -Availability zone in which this host is running. - -type: keyword - -example: us-east-1c +type: keyword -- -*`cloud.instance.id`*:: +*`destination.user.group.name`*:: + -- -Instance ID of the host machine. +Name of the group. type: keyword -example: i-1234567890abcdef0 - -- -*`cloud.instance.name`*:: +*`destination.user.hash`*:: + -- -Instance name of the host machine. +Unique user hash to correlate information for a user in anonymized form. +Useful if `user.id` or `user.name` contain confidential information and cannot be used. type: keyword -- -*`cloud.machine.type`*:: +*`destination.user.id`*:: + -- -Machine type of the host machine. +One or multiple unique identifiers of the user. type: keyword -example: t2.medium - -- -*`cloud.provider`*:: +*`destination.user.name`*:: + -- -Name of the cloud provider. Example values are aws, azure, gcp, or digitalocean. +Short name or login of the user. type: keyword -example: aws +example: albert -- -*`cloud.region`*:: +*`destination.user.name.text`*:: + -- -Region in which this host is running. - -type: keyword - -example: us-east-1 +type: text -- [float] -=== container +=== dns -Container fields are used for meta information about the specific container that is the source of information. -These fields help correlate data based containers from any runtime. +Fields describing DNS queries and answers. +DNS events should either represent a single DNS query prior to getting answers (`dns.type:query`) or they should represent a full exchange and contain the query details as well as all of the answers that were provided for this query (`dns.type:answer`). -*`container.id`*:: +*`dns.answers`*:: + -- -Unique container id. +An array containing an object for each answer section returned by the server. +The main keys that should be present in these objects are defined by ECS. Records that have more information may contain more keys than what ECS defines. +Not all DNS data sources give all details about DNS answers. At minimum, answer objects must contain the `data` key. If more information is available, map as much of it to ECS as possible, and add any additional fields to the answer objects as custom fields. -type: keyword +type: object -- -*`container.image.name`*:: +*`dns.answers.class`*:: + -- -Name of the image the container was built on. +The class of DNS data contained in this resource record. type: keyword +example: IN + -- -*`container.image.tag`*:: +*`dns.answers.data`*:: + -- -Container image tag. +The data describing the resource. +The meaning of this data depends on the type and class of the resource record. type: keyword --- - -*`container.labels`*:: -+ --- -Image labels. - -type: object +example: 10.10.10.10 -- -*`container.name`*:: +*`dns.answers.name`*:: + -- -Container name. +The domain name to which this resource record pertains. +If a chain of CNAME is being resolved, each answer's `name` should be the one that corresponds with the answer's `data`. It should not simply be the original `question.name` repeated. type: keyword +example: www.google.com + -- -*`container.runtime`*:: +*`dns.answers.ttl`*:: + -- -Runtime managing this container. +The time interval in seconds that this resource record may be cached before it should be discarded. Zero values mean that the data should not be cached. -type: keyword +type: long -example: docker +example: 180 -- -[float] -=== destination - -Destination fields describe details about the destination of a packet/event. -Destination fields are usually populated in conjunction with source fields. - - -*`destination.address`*:: +*`dns.answers.type`*:: + -- -Some event destination addresses are defined ambiguously. The event will sometimes list an IP, a domain or a unix socket. You should always store the raw address in the `.address` field. -Then it should be duplicated to `.ip` or `.domain`, depending on which one it is. +The type of data contained in this resource record. type: keyword +example: CNAME + -- -*`destination.as.number`*:: +*`dns.header_flags`*:: + -- -Unique number allocated to the autonomous system. The autonomous system number (ASN) uniquely identifies each network on the Internet. +Array of 2 letter DNS header flags. +Expected values are: AA, TC, RD, RA, AD, CD, DO. -type: long +type: keyword -example: 15169 +example: ['RD', 'RA'] -- -*`destination.as.organization.name`*:: +*`dns.id`*:: + -- -Organization name. +The DNS packet identifier assigned by the program that generated the query. The identifier is copied to the response. type: keyword -example: Google LLC +example: 62111 -- -*`destination.as.organization.name.text`*:: +*`dns.op_code`*:: + -- -type: text +The DNS operation code that specifies the kind of query in the message. This value is set by the originator of a query and copied into the response. + +type: keyword + +example: QUERY -- -*`destination.bytes`*:: +*`dns.question.class`*:: + -- -Bytes sent from the destination to the source. - -type: long +The class of records being queried. -example: 184 +type: keyword -format: bytes +example: IN -- -*`destination.domain`*:: +*`dns.question.name`*:: + -- -Destination domain. +The name being queried. +If the name field contains non-printable characters (below 32 or above 126), those characters should be represented as escaped base 10 integers (\DDD). Back slashes and quotes should be escaped. Tabs, carriage returns, and line feeds should be converted to \t, \r, and \n respectively. type: keyword +example: www.google.com + -- -*`destination.geo.city_name`*:: +*`dns.question.registered_domain`*:: + -- -City name. +The highest registered domain, stripped of the subdomain. +For example, the registered domain for "foo.google.com" is "google.com". +This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last two labels will not work well for TLDs such as "co.uk". type: keyword -example: Montreal +example: google.com -- -*`destination.geo.continent_name`*:: +*`dns.question.subdomain`*:: + -- -Name of the continent. +The subdomain is all of the labels under the registered_domain. +If the domain has multiple levels of subdomain, such as "sub2.sub1.example.com", the subdomain field should contain "sub2.sub1", with no trailing period. type: keyword -example: North America +example: www -- -*`destination.geo.country_iso_code`*:: +*`dns.question.top_level_domain`*:: + -- -Country ISO code. +The effective top level domain (eTLD), also known as the domain suffix, is the last part of the domain name. For example, the top level domain for google.com is "com". +This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last label will not work well for effective TLDs such as "co.uk". type: keyword -example: CA +example: co.uk -- -*`destination.geo.country_name`*:: +*`dns.question.type`*:: + -- -Country name. +The type of record being queried. type: keyword -example: Canada +example: AAAA -- -*`destination.geo.location`*:: +*`dns.resolved_ip`*:: + -- -Longitude and latitude. +Array containing all IPs seen in `answers.data`. +The `answers` array can be difficult to use, because of the variety of data formats it can contain. Extracting all IP addresses seen in there to `dns.resolved_ip` makes it possible to index them as IP addresses, and makes them easier to visualize and query for. -type: geo_point +type: ip -example: { "lon": -73.614830, "lat": 45.505918 } +example: ['10.10.10.10', '10.10.10.11'] -- -*`destination.geo.name`*:: +*`dns.response_code`*:: + -- -User-defined description of a location, at the level of granularity they care about. -Could be the name of their data centers, the floor number, if this describes a local physical entity, city names. -Not typically used in automated geolocation. +The DNS response code. type: keyword -example: boston-dc +example: NOERROR -- -*`destination.geo.region_iso_code`*:: +*`dns.type`*:: + -- -Region ISO code. +The type of DNS event captured, query or answer. +If your source of DNS events only gives you DNS queries, you should only create dns events of type `dns.type:query`. +If your source of DNS events gives you answers as well, you should create one event per query (optionally as soon as the query is seen). And a second event containing all query details as well as an array of answers. type: keyword -example: CA-QC +example: answer -- -*`destination.geo.region_name`*:: +[float] +=== ecs + +Meta-information specific to ECS. + + +*`ecs.version`*:: + -- -Region name. +ECS version this event conforms to. `ecs.version` is a required field and must exist in all events. +When querying across multiple indices -- which may conform to slightly different ECS versions -- this field lets integrations adjust to the schema version of the events. type: keyword -example: Quebec +example: 1.0.0 + +required: True -- -*`destination.ip`*:: +[float] +=== error + +These fields can represent errors of any kind. +Use them for errors that happen while fetching events or in cases where the event itself contains an error. + + +*`error.code`*:: + -- -IP address of the destination. -Can be one or multiple IPv4 or IPv6 addresses. +Error code describing the error. -type: ip +type: keyword -- -*`destination.mac`*:: +*`error.id`*:: + -- -MAC address of the destination. +Unique identifier for the error. type: keyword -- -*`destination.nat.ip`*:: +*`error.message`*:: + -- -Translated ip of destination based NAT sessions (e.g. internet to private DMZ) -Typically used with load balancers, firewalls, or routers. +Error message. -type: ip +type: text -- -*`destination.nat.port`*:: +*`error.stack_trace`*:: + -- -Port the source session is translated to by NAT Device. -Typically used with load balancers, firewalls, or routers. - -type: long +The stack trace of this error in plain text. -format: string +type: keyword -- -*`destination.packets`*:: +*`error.stack_trace.text`*:: + -- -Packets sent from the destination to the source. - -type: long - -example: 12 +type: text -- -*`destination.port`*:: +*`error.type`*:: + -- -Port of the destination. +The type of the error, for example the class name of the exception. -type: long +type: keyword + +example: java.lang.NullPointerException + +-- + +[float] +=== event -format: string +The event fields are used for context information about the log or metric event itself. +A log is defined as an event containing details of something that happened. Log events must include the time at which the thing happened. Examples of log events include a process starting on a host, a network packet being sent from a source to a destination, or a network connection between a client and a server being initiated or closed. A metric is defined as an event containing one or more numerical or categorical measurements and the time at which the measurement was taken. Examples of metric events include memory pressure measured on a host, or vulnerabilities measured on a scanned host. --- -*`destination.registered_domain`*:: +*`event.action`*:: + -- -The highest registered destination domain, stripped of the subdomain. -For example, the registered domain for "foo.google.com" is "google.com". -This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last two labels will not work well for TLDs such as "co.uk". +The action captured by the event. +This describes the information in the event. It is more specific than `event.category`. Examples are `group-add`, `process-started`, `file-created`. The value is normally defined by the implementer. type: keyword -example: google.com +example: user-password-change -- -*`destination.top_level_domain`*:: +*`event.category`*:: + -- -The effective top level domain (eTLD), also known as the domain suffix, is the last part of the domain name. For example, the top level domain for google.com is "com". -This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last label will not work well for effective TLDs such as "co.uk". +This is one of four ECS Categorization Fields, and indicates the second level in the ECS category hierarchy. +`event.category` represents the "big buckets" of ECS categories. For example, filtering on `event.category:process` yields all events relating to process activity. This field is closely related to `event.type`, which is used as a subcategory. +This field is an array. This will allow proper categorization of some events that fall in multiple categories. type: keyword -example: co.uk +example: authentication -- -*`destination.user.domain`*:: +*`event.code`*:: + -- -Name of the directory the user is a member of. -For example, an LDAP or Active Directory domain name. +Identification code for this event, if one exists. +Some event sources use event codes to identify messages unambiguously, regardless of message language or wording adjustments over time. An example of this is the Windows Event ID. type: keyword +example: 4648 + -- -*`destination.user.email`*:: +*`event.created`*:: + -- -User email address. +event.created contains the date/time when the event was first read by an agent, or by your pipeline. +This field is distinct from @timestamp in that @timestamp typically contain the time extracted from the original event. +In most situations, these two timestamps will be slightly different. The difference can be used to calculate the delay between your source generating an event, and the time when your agent first processed it. This can be used to monitor your agent's or pipeline's ability to keep up with your event source. +In case the two timestamps are identical, @timestamp should be used. -type: keyword +type: date + +example: 2016-05-23 08:05:34.857000 -- -*`destination.user.full_name`*:: +*`event.dataset`*:: + -- -User's full name, if available. +Name of the dataset. +If an event source publishes more than one type of log or events (e.g. access log, error log), the dataset is used to specify which one the event comes from. +It's recommended but not required to start the dataset name with the module name, followed by a dot, then the dataset name. type: keyword -example: Albert Einstein +example: apache.access -- -*`destination.user.full_name.text`*:: +*`event.duration`*:: + -- -type: text +Duration of the event in nanoseconds. +If event.start and event.end are known this value should be the difference between the end and start time. + +type: long + +format: duration -- -*`destination.user.group.domain`*:: +*`event.end`*:: + -- -Name of the directory the group is a member of. -For example, an LDAP or Active Directory domain name. +event.end contains the date when the event ended or when the activity was last observed. -type: keyword +type: date -- -*`destination.user.group.id`*:: +*`event.hash`*:: + -- -Unique identifier for the group on the system/platform. +Hash (perhaps logstash fingerprint) of raw field to be able to demonstrate log integrity. type: keyword +example: 123456789012345678901234567890ABCD + -- -*`destination.user.group.name`*:: +*`event.id`*:: + -- -Name of the group. +Unique ID to describe the event. type: keyword +example: 8a4f500d + -- -*`destination.user.hash`*:: +*`event.ingested`*:: + -- -Unique user hash to correlate information for a user in anonymized form. -Useful if `user.id` or `user.name` contain confidential information and cannot be used. +Timestamp when an event arrived in the central data store. +This is different from `@timestamp`, which is when the event originally occurred. It's also different from `event.created`, which is meant to capture the first time an agent saw the event. +In normal conditions, assuming no tampering, the timestamps should chronologically look like this: `@timestamp` < `event.created` < `event.ingested`. -type: keyword +type: date + +example: 2016-05-23 08:05:35.101000 -- -*`destination.user.id`*:: +*`event.kind`*:: + -- -One or multiple unique identifiers of the user. +This is one of four ECS Categorization Fields, and indicates the highest level in the ECS category hierarchy. +`event.kind` gives high-level information about what type of information the event contains, without being specific to the contents of the event. For example, values of this field distinguish alert events from metric events. +The value of this field can be used to inform how these kinds of events should be handled. They may warrant different retention, different access control, it may also help understand whether the data coming in at a regular interval or not. type: keyword +example: alert + -- -*`destination.user.name`*:: +*`event.module`*:: + -- -Short name or login of the user. +Name of the module this data is coming from. +If your monitoring agent supports the concept of modules or plugins to process events of a given source (e.g. Apache logs), `event.module` should contain the name of this module. type: keyword -example: albert +example: apache -- -*`destination.user.name.text`*:: +*`event.original`*:: + -- -type: text - --- +Raw text message of entire event. Used to demonstrate log integrity. +This field is not indexed and doc_values are disabled. It cannot be searched, but it can be retrieved from `_source`. -[float] -=== dns +type: keyword -Fields describing DNS queries and answers. -DNS events should either represent a single DNS query prior to getting answers (`dns.type:query`) or they should represent a full exchange and contain the query details as well as all of the answers that were provided for this query (`dns.type:answer`). +example: Sep 19 08:26:10 host CEF:0|Security| threatmanager|1.0|100| worm successfully stopped|10|src=10.0.0.1 dst=2.1.2.2spt=1232 +-- -*`dns.answers`*:: +*`event.outcome`*:: + -- -An array containing an object for each answer section returned by the server. -The main keys that should be present in these objects are defined by ECS. Records that have more information may contain more keys than what ECS defines. -Not all DNS data sources give all details about DNS answers. At minimum, answer objects must contain the `data` key. If more information is available, map as much of it to ECS as possible, and add any additional fields to the answer objects as custom fields. +This is one of four ECS Categorization Fields, and indicates the lowest level in the ECS category hierarchy. +`event.outcome` simply denotes whether the event represent a success or a failure. Note that not all events will have an associated outcome. For example, this field is generally not populated for metric events or events with `event.type:info`. -type: object +type: keyword + +example: success -- -*`dns.answers.class`*:: +*`event.provider`*:: + -- -The class of DNS data contained in this resource record. +Source of the event. +Event transports such as Syslog or the Windows Event Log typically mention the source of an event. It can be the name of the software that generated the event (e.g. Sysmon, httpd), or of a subsystem of the operating system (kernel, Microsoft-Windows-Security-Auditing). type: keyword -example: IN +example: kernel -- -*`dns.answers.data`*:: +*`event.risk_score`*:: + -- -The data describing the resource. -The meaning of this data depends on the type and class of the resource record. - -type: keyword +Risk score or priority of the event (e.g. security solutions). Use your system's original value here. -example: 10.10.10.10 +type: float -- -*`dns.answers.name`*:: +*`event.risk_score_norm`*:: + -- -The domain name to which this resource record pertains. -If a chain of CNAME is being resolved, each answer's `name` should be the one that corresponds with the answer's `data`. It should not simply be the original `question.name` repeated. - -type: keyword +Normalized risk score or priority of the event, on a scale of 0 to 100. +This is mainly useful if you use more than one system that assigns risk scores, and you want to see a normalized value across all systems. -example: www.google.com +type: float -- -*`dns.answers.ttl`*:: +*`event.sequence`*:: + -- -The time interval in seconds that this resource record may be cached before it should be discarded. Zero values mean that the data should not be cached. +Sequence number of the event. +The sequence number is a value published by some event sources, to make the exact ordering of events unambiguous, regarless of the timestamp precision. type: long -example: 180 +format: string -- -*`dns.answers.type`*:: +*`event.severity`*:: + -- -The type of data contained in this resource record. +The numeric severity of the event according to your event source. +What the different severity values mean can be different between sources and use cases. It's up to the implementer to make sure severities are consistent across events from the same source. +The Syslog severity belongs in `log.syslog.severity.code`. `event.severity` is meant to represent the severity according to the event source (e.g. firewall, IDS). If the event source does not publish its own severity, you may optionally copy the `log.syslog.severity.code` to `event.severity`. -type: keyword +type: long -example: CNAME +example: 7 + +format: string -- -*`dns.header_flags`*:: +*`event.start`*:: + -- -Array of 2 letter DNS header flags. -Expected values are: AA, TC, RD, RA, AD, CD, DO. - -type: keyword +event.start contains the date when the event started or when the activity was first observed. -example: ['RD', 'RA'] +type: date -- -*`dns.id`*:: +*`event.timezone`*:: + -- -The DNS packet identifier assigned by the program that generated the query. The identifier is copied to the response. +This field should be populated when the event's timestamp does not include timezone information already (e.g. default Syslog timestamps). It's optional otherwise. +Acceptable timezone formats are: a canonical ID (e.g. "Europe/Amsterdam"), abbreviated (e.g. "EST") or an HH:mm differential (e.g. "-05:00"). type: keyword -example: 62111 - -- -*`dns.op_code`*:: +*`event.type`*:: + -- -The DNS operation code that specifies the kind of query in the message. This value is set by the originator of a query and copied into the response. +This is one of four ECS Categorization Fields, and indicates the third level in the ECS category hierarchy. +`event.type` represents a categorization "sub-bucket" that, when used along with the `event.category` field values, enables filtering events down to a level appropriate for single visualization. +This field is an array. This will allow proper categorization of some events that fall in multiple event types. type: keyword -example: QUERY - --- - -*`dns.question.class`*:: -+ -- -The class of records being queried. -type: keyword +[float] +=== file -example: IN +A file is defined as a set of information that has been created on, or has existed on a filesystem. +File objects can be associated with host events, network events, and/or file events (e.g., those produced by File Integrity Monitoring [FIM] products or services). File fields provide details about the affected file associated with the event or metric. --- -*`dns.question.name`*:: +*`file.accessed`*:: + -- -The name being queried. -If the name field contains non-printable characters (below 32 or above 126), those characters should be represented as escaped base 10 integers (\DDD). Back slashes and quotes should be escaped. Tabs, carriage returns, and line feeds should be converted to \t, \r, and \n respectively. - -type: keyword +Last time the file was accessed. +Note that not all filesystems keep track of access time. -example: www.google.com +type: date -- -*`dns.question.registered_domain`*:: +*`file.attributes`*:: + -- -The highest registered domain, stripped of the subdomain. -For example, the registered domain for "foo.google.com" is "google.com". -This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last two labels will not work well for TLDs such as "co.uk". +Array of file attributes. +Attributes names will vary by platform. Here's a non-exhaustive list of values that are expected in this field: archive, compressed, directory, encrypted, execute, hidden, read, readonly, system, write. type: keyword -example: google.com +example: ["readonly", "system"] -- -*`dns.question.subdomain`*:: +*`file.created`*:: + -- -The subdomain is all of the labels under the registered_domain. -If the domain has multiple levels of subdomain, such as "sub2.sub1.example.com", the subdomain field should contain "sub2.sub1", with no trailing period. - -type: keyword +File creation time. +Note that not all filesystems store the creation time. -example: www +type: date -- -*`dns.question.top_level_domain`*:: +*`file.ctime`*:: + -- -The effective top level domain (eTLD), also known as the domain suffix, is the last part of the domain name. For example, the top level domain for google.com is "com". -This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last label will not work well for effective TLDs such as "co.uk". - -type: keyword +Last time the file attributes or metadata changed. +Note that changes to the file content will update `mtime`. This implies `ctime` will be adjusted at the same time, since `mtime` is an attribute of the file. -example: co.uk +type: date -- -*`dns.question.type`*:: +*`file.device`*:: + -- -The type of record being queried. +Device that is the source of the file. type: keyword -example: AAAA +example: sda -- -*`dns.resolved_ip`*:: +*`file.directory`*:: + -- -Array containing all IPs seen in `answers.data`. -The `answers` array can be difficult to use, because of the variety of data formats it can contain. Extracting all IP addresses seen in there to `dns.resolved_ip` makes it possible to index them as IP addresses, and makes them easier to visualize and query for. +Directory where the file is located. It should include the drive letter, when appropriate. -type: ip +type: keyword -example: ['10.10.10.10', '10.10.10.11'] +example: /home/alice -- -*`dns.response_code`*:: +*`file.drive_letter`*:: + -- -The DNS response code. +Drive letter where the file is located. This field is only relevant on Windows. +The value should be uppercase, and not include the colon. type: keyword -example: NOERROR +example: C -- -*`dns.type`*:: +*`file.extension`*:: + -- -The type of DNS event captured, query or answer. -If your source of DNS events only gives you DNS queries, you should only create dns events of type `dns.type:query`. -If your source of DNS events gives you answers as well, you should create one event per query (optionally as soon as the query is seen). And a second event containing all query details as well as an array of answers. +File extension. type: keyword -example: answer +example: png -- -[float] -=== ecs - -Meta-information specific to ECS. - - -*`ecs.version`*:: +*`file.gid`*:: + -- -ECS version this event conforms to. `ecs.version` is a required field and must exist in all events. -When querying across multiple indices -- which may conform to slightly different ECS versions -- this field lets integrations adjust to the schema version of the events. +Primary group ID (GID) of the file. type: keyword -example: 1.0.0 +example: 1001 -required: True +-- +*`file.group`*:: ++ -- +Primary group name of the file. -[float] -=== error +type: keyword -These fields can represent errors of any kind. -Use them for errors that happen while fetching events or in cases where the event itself contains an error. +example: alice +-- -*`error.code`*:: +*`file.hash.md5`*:: + -- -Error code describing the error. +MD5 hash. type: keyword -- -*`error.id`*:: +*`file.hash.sha1`*:: + -- -Unique identifier for the error. +SHA1 hash. type: keyword -- -*`error.message`*:: +*`file.hash.sha256`*:: + -- -Error message. +SHA256 hash. -type: text +type: keyword -- -*`error.stack_trace`*:: +*`file.hash.sha512`*:: + -- -The stack trace of this error in plain text. +SHA512 hash. type: keyword -- -*`error.stack_trace.text`*:: +*`file.inode`*:: + -- -type: text +Inode representing the file in the filesystem. + +type: keyword + +example: 256383 -- -*`error.type`*:: +*`file.mode`*:: + -- -The type of the error, for example the class name of the exception. +Mode of the file in octal representation. type: keyword -example: java.lang.NullPointerException +example: 0640 -- -[float] -=== event +*`file.mtime`*:: ++ +-- +Last time the file content was modified. -The event fields are used for context information about the log or metric event itself. -A log is defined as an event containing details of something that happened. Log events must include the time at which the thing happened. Examples of log events include a process starting on a host, a network packet being sent from a source to a destination, or a network connection between a client and a server being initiated or closed. A metric is defined as an event containing one or more numerical or categorical measurements and the time at which the measurement was taken. Examples of metric events include memory pressure measured on a host, or vulnerabilities measured on a scanned host. +type: date +-- -*`event.action`*:: +*`file.name`*:: + -- -The action captured by the event. -This describes the information in the event. It is more specific than `event.category`. Examples are `group-add`, `process-started`, `file-created`. The value is normally defined by the implementer. +Name of the file including the extension, without the directory. type: keyword -example: user-password-change +example: example.png -- -*`event.category`*:: +*`file.owner`*:: + -- -This is one of four ECS Categorization Fields, and indicates the second level in the ECS category hierarchy. -`event.category` represents the "big buckets" of ECS categories. For example, filtering on `event.category:process` yields all events relating to process activity. This field is closely related to `event.type`, which is used as a subcategory. -This field is an array. This will allow proper categorization of some events that fall in multiple categories. +File owner's username. type: keyword -example: authentication +example: alice -- -*`event.code`*:: +*`file.path`*:: + -- -Identification code for this event, if one exists. -Some event sources use event codes to identify messages unambiguously, regardless of message language or wording adjustments over time. An example of this is the Windows Event ID. +Full path to the file, including the file name. It should include the drive letter, when appropriate. type: keyword -example: 4648 +example: /home/alice/example.png -- -*`event.created`*:: +*`file.path.text`*:: + -- -event.created contains the date/time when the event was first read by an agent, or by your pipeline. -This field is distinct from @timestamp in that @timestamp typically contain the time extracted from the original event. -In most situations, these two timestamps will be slightly different. The difference can be used to calculate the delay between your source generating an event, and the time when your agent first processed it. This can be used to monitor your agent's or pipeline's ability to keep up with your event source. -In case the two timestamps are identical, @timestamp should be used. - -type: date - -example: 2016-05-23 08:05:34.857000 +type: text -- -*`event.dataset`*:: +*`file.size`*:: + -- -Name of the dataset. -If an event source publishes more than one type of log or events (e.g. access log, error log), the dataset is used to specify which one the event comes from. -It's recommended but not required to start the dataset name with the module name, followed by a dot, then the dataset name. +File size in bytes. +Only relevant when `file.type` is "file". -type: keyword +type: long -example: apache.access +example: 16384 -- -*`event.duration`*:: +*`file.target_path`*:: + -- -Duration of the event in nanoseconds. -If event.start and event.end are known this value should be the difference between the end and start time. - -type: long +Target path for symlinks. -format: duration +type: keyword -- -*`event.end`*:: +*`file.target_path.text`*:: + -- -event.end contains the date when the event ended or when the activity was last observed. - -type: date +type: text -- -*`event.hash`*:: +*`file.type`*:: + -- -Hash (perhaps logstash fingerprint) of raw field to be able to demonstrate log integrity. +File type (file, dir, or symlink). type: keyword -example: 123456789012345678901234567890ABCD +example: file -- -*`event.id`*:: +*`file.uid`*:: + -- -Unique ID to describe the event. +The user ID (UID) or security identifier (SID) of the file owner. type: keyword -example: 8a4f500d - --- +example: 1001 -*`event.ingested`*:: -+ -- -Timestamp when an event arrived in the central data store. -This is different from `@timestamp`, which is when the event originally occurred. It's also different from `event.created`, which is meant to capture the first time an agent saw the event. -In normal conditions, assuming no tampering, the timestamps should chronologically look like this: `@timestamp` < `event.created` < `event.ingested`. -type: date +[float] +=== geo -example: 2016-05-23 08:05:35.101000 +Geo fields can carry data about a specific location related to an event. +This geolocation information can be derived from techniques such as Geo IP, or be user-supplied. --- -*`event.kind`*:: +*`geo.city_name`*:: + -- -This is one of four ECS Categorization Fields, and indicates the highest level in the ECS category hierarchy. -`event.kind` gives high-level information about what type of information the event contains, without being specific to the contents of the event. For example, values of this field distinguish alert events from metric events. -The value of this field can be used to inform how these kinds of events should be handled. They may warrant different retention, different access control, it may also help understand whether the data coming in at a regular interval or not. +City name. type: keyword -example: alert +example: Montreal -- -*`event.module`*:: +*`geo.continent_name`*:: + -- -Name of the module this data is coming from. -If your monitoring agent supports the concept of modules or plugins to process events of a given source (e.g. Apache logs), `event.module` should contain the name of this module. +Name of the continent. type: keyword -example: apache +example: North America -- -*`event.original`*:: +*`geo.country_iso_code`*:: + -- -Raw text message of entire event. Used to demonstrate log integrity. -This field is not indexed and doc_values are disabled. It cannot be searched, but it can be retrieved from `_source`. +Country ISO code. type: keyword -example: Sep 19 08:26:10 host CEF:0|Security| threatmanager|1.0|100| worm successfully stopped|10|src=10.0.0.1 dst=2.1.2.2spt=1232 +example: CA -- -*`event.outcome`*:: +*`geo.country_name`*:: + -- -This is one of four ECS Categorization Fields, and indicates the lowest level in the ECS category hierarchy. -`event.outcome` simply denotes whether the event represent a success or a failure. Note that not all events will have an associated outcome. For example, this field is generally not populated for metric events or events with `event.type:info`. +Country name. type: keyword -example: success +example: Canada -- -*`event.provider`*:: +*`geo.location`*:: + -- -Source of the event. -Event transports such as Syslog or the Windows Event Log typically mention the source of an event. It can be the name of the software that generated the event (e.g. Sysmon, httpd), or of a subsystem of the operating system (kernel, Microsoft-Windows-Security-Auditing). +Longitude and latitude. -type: keyword +type: geo_point -example: kernel +example: { "lon": -73.614830, "lat": 45.505918 } -- -*`event.risk_score`*:: +*`geo.name`*:: + -- -Risk score or priority of the event (e.g. security solutions). Use your system's original value here. +User-defined description of a location, at the level of granularity they care about. +Could be the name of their data centers, the floor number, if this describes a local physical entity, city names. +Not typically used in automated geolocation. -type: float +type: keyword + +example: boston-dc -- -*`event.risk_score_norm`*:: +*`geo.region_iso_code`*:: + -- -Normalized risk score or priority of the event, on a scale of 0 to 100. -This is mainly useful if you use more than one system that assigns risk scores, and you want to see a normalized value across all systems. +Region ISO code. -type: float +type: keyword + +example: CA-QC -- -*`event.sequence`*:: +*`geo.region_name`*:: + -- -Sequence number of the event. -The sequence number is a value published by some event sources, to make the exact ordering of events unambiguous, regarless of the timestamp precision. - -type: long +Region name. -format: string +type: keyword --- +example: Quebec -*`event.severity`*:: -+ -- -The numeric severity of the event according to your event source. -What the different severity values mean can be different between sources and use cases. It's up to the implementer to make sure severities are consistent across events from the same source. -The Syslog severity belongs in `log.syslog.severity.code`. `event.severity` is meant to represent the severity according to the event source (e.g. firewall, IDS). If the event source does not publish its own severity, you may optionally copy the `log.syslog.severity.code` to `event.severity`. - -type: long -example: 7 +[float] +=== group -format: string +The group fields are meant to represent groups that are relevant to the event. --- -*`event.start`*:: +*`group.domain`*:: + -- -event.start contains the date when the event started or when the activity was first observed. +Name of the directory the group is a member of. +For example, an LDAP or Active Directory domain name. -type: date +type: keyword -- -*`event.timezone`*:: +*`group.id`*:: + -- -This field should be populated when the event's timestamp does not include timezone information already (e.g. default Syslog timestamps). It's optional otherwise. -Acceptable timezone formats are: a canonical ID (e.g. "Europe/Amsterdam"), abbreviated (e.g. "EST") or an HH:mm differential (e.g. "-05:00"). +Unique identifier for the group on the system/platform. type: keyword -- -*`event.type`*:: +*`group.name`*:: + -- -This is one of four ECS Categorization Fields, and indicates the third level in the ECS category hierarchy. -`event.type` represents a categorization "sub-bucket" that, when used along with the `event.category` field values, enables filtering events down to a level appropriate for single visualization. -This field is an array. This will allow proper categorization of some events that fall in multiple event types. +Name of the group. type: keyword -- [float] -=== file +=== hash -A file is defined as a set of information that has been created on, or has existed on a filesystem. -File objects can be associated with host events, network events, and/or file events (e.g., those produced by File Integrity Monitoring [FIM] products or services). File fields provide details about the affected file associated with the event or metric. +The hash fields represent different hash algorithms and their values. +Field names for common hashes (e.g. MD5, SHA1) are predefined. Add fields for other hashes by lowercasing the hash algorithm name and using underscore separators as appropriate (snake case, e.g. sha3_512). -*`file.accessed`*:: +*`hash.md5`*:: + -- -Last time the file was accessed. -Note that not all filesystems keep track of access time. +MD5 hash. -type: date +type: keyword -- -*`file.attributes`*:: +*`hash.sha1`*:: + -- -Array of file attributes. -Attributes names will vary by platform. Here's a non-exhaustive list of values that are expected in this field: archive, compressed, directory, encrypted, execute, hidden, read, readonly, system, write. +SHA1 hash. type: keyword -example: ["readonly", "system"] - -- -*`file.created`*:: +*`hash.sha256`*:: + -- -File creation time. -Note that not all filesystems store the creation time. +SHA256 hash. -type: date +type: keyword -- -*`file.ctime`*:: +*`hash.sha512`*:: + -- -Last time the file attributes or metadata changed. -Note that changes to the file content will update `mtime`. This implies `ctime` will be adjusted at the same time, since `mtime` is an attribute of the file. - -type: date +SHA512 hash. --- +type: keyword -*`file.device`*:: -+ -- -Device that is the source of the file. -type: keyword +[float] +=== host -example: sda +A host is defined as a general computing instance. +ECS host.* fields should be populated with details about the host on which the event happened, or from which the measurement was taken. Host types include hardware, virtual machines, Docker containers, and Kubernetes nodes. --- -*`file.directory`*:: +*`host.architecture`*:: + -- -Directory where the file is located. It should include the drive letter, when appropriate. +Operating system architecture. type: keyword -example: /home/alice +example: x86_64 -- -*`file.drive_letter`*:: +*`host.domain`*:: + -- -Drive letter where the file is located. This field is only relevant on Windows. -The value should be uppercase, and not include the colon. +Name of the domain of which the host is a member. +For example, on Windows this could be the host's Active Directory domain or NetBIOS domain name. For Linux this could be the domain of the host's LDAP provider. type: keyword -example: C +example: CONTOSO -- -*`file.extension`*:: +*`host.geo.city_name`*:: + -- -File extension. +City name. type: keyword -example: png +example: Montreal -- -*`file.gid`*:: +*`host.geo.continent_name`*:: + -- -Primary group ID (GID) of the file. +Name of the continent. type: keyword -example: 1001 +example: North America -- -*`file.group`*:: +*`host.geo.country_iso_code`*:: + -- -Primary group name of the file. +Country ISO code. type: keyword -example: alice +example: CA -- -*`file.hash.md5`*:: +*`host.geo.country_name`*:: + -- -MD5 hash. +Country name. type: keyword --- - -*`file.hash.sha1`*:: -+ --- -SHA1 hash. - -type: keyword +example: Canada -- -*`file.hash.sha256`*:: +*`host.geo.location`*:: + -- -SHA256 hash. +Longitude and latitude. -type: keyword +type: geo_point + +example: { "lon": -73.614830, "lat": 45.505918 } -- -*`file.hash.sha512`*:: +*`host.geo.name`*:: + -- -SHA512 hash. +User-defined description of a location, at the level of granularity they care about. +Could be the name of their data centers, the floor number, if this describes a local physical entity, city names. +Not typically used in automated geolocation. type: keyword +example: boston-dc + -- -*`file.inode`*:: +*`host.geo.region_iso_code`*:: + -- -Inode representing the file in the filesystem. +Region ISO code. type: keyword -example: 256383 +example: CA-QC -- -*`file.mode`*:: +*`host.geo.region_name`*:: + -- -Mode of the file in octal representation. +Region name. type: keyword -example: 0640 +example: Quebec -- -*`file.mtime`*:: +*`host.hostname`*:: + -- -Last time the file content was modified. +Hostname of the host. +It normally contains what the `hostname` command returns on the host machine. -type: date +type: keyword -- -*`file.name`*:: +*`host.id`*:: + -- -Name of the file including the extension, without the directory. +Unique host id. +As hostname is not always unique, use values that are meaningful in your environment. +Example: The current usage of `beat.name`. type: keyword -example: example.png - -- -*`file.owner`*:: +*`host.ip`*:: + -- -File owner's username. - -type: keyword +Host ip address. -example: alice +type: ip -- -*`file.path`*:: +*`host.mac`*:: + -- -Full path to the file, including the file name. It should include the drive letter, when appropriate. +Host mac address. type: keyword -example: /home/alice/example.png - -- -*`file.path.text`*:: +*`host.name`*:: + -- -type: text +Name of the host. +It can contain what `hostname` returns on Unix systems, the fully qualified domain name, or a name specified by the user. The sender decides which value to use. + +type: keyword -- -*`file.size`*:: +*`host.os.family`*:: + -- -File size in bytes. -Only relevant when `file.type` is "file". +OS family (such as redhat, debian, freebsd, windows). -type: long +type: keyword -example: 16384 +example: debian -- -*`file.target_path`*:: +*`host.os.full`*:: + -- -Target path for symlinks. +Operating system name, including the version or code name. type: keyword +example: Mac OS Mojave + -- -*`file.target_path.text`*:: +*`host.os.full.text`*:: + -- type: text -- -*`file.type`*:: +*`host.os.kernel`*:: + -- -File type (file, dir, or symlink). +Operating system kernel version as a raw string. type: keyword -example: file +example: 4.4.0-112-generic -- -*`file.uid`*:: +*`host.os.name`*:: + -- -The user ID (UID) or security identifier (SID) of the file owner. +Operating system name, without the version. type: keyword -example: 1001 +example: Mac OS X -- -[float] -=== geo - -Geo fields can carry data about a specific location related to an event. -This geolocation information can be derived from techniques such as Geo IP, or be user-supplied. - - -*`geo.city_name`*:: +*`host.os.name.text`*:: + -- -City name. - -type: keyword - -example: Montreal +type: text -- -*`geo.continent_name`*:: +*`host.os.platform`*:: + -- -Name of the continent. +Operating system platform (such centos, ubuntu, windows). type: keyword -example: North America +example: darwin -- -*`geo.country_iso_code`*:: +*`host.os.version`*:: + -- -Country ISO code. +Operating system version as a raw string. type: keyword -example: CA +example: 10.14.1 -- -*`geo.country_name`*:: +*`host.type`*:: + -- -Country name. +Type of host. +For Cloud providers this can be the machine type like `t2.medium`. If vm, this could be the container, for example, or other information meaningful in your environment. type: keyword -example: Canada - -- -*`geo.location`*:: +*`host.uptime`*:: + -- -Longitude and latitude. +Seconds the host has been up. -type: geo_point +type: long -example: { "lon": -73.614830, "lat": 45.505918 } +example: 1325 -- -*`geo.name`*:: +*`host.user.domain`*:: + -- -User-defined description of a location, at the level of granularity they care about. -Could be the name of their data centers, the floor number, if this describes a local physical entity, city names. -Not typically used in automated geolocation. +Name of the directory the user is a member of. +For example, an LDAP or Active Directory domain name. type: keyword -example: boston-dc - -- -*`geo.region_iso_code`*:: +*`host.user.email`*:: + -- -Region ISO code. +User email address. type: keyword -example: CA-QC - -- -*`geo.region_name`*:: +*`host.user.full_name`*:: + -- -Region name. +User's full name, if available. type: keyword -example: Quebec +example: Albert Einstein -- -[float] -=== group - -The group fields are meant to represent groups that are relevant to the event. +*`host.user.full_name.text`*:: ++ +-- +type: text +-- -*`group.domain`*:: +*`host.user.group.domain`*:: + -- Name of the directory the group is a member of. @@ -8002,7 +9107,7 @@ type: keyword -- -*`group.id`*:: +*`host.user.group.id`*:: + -- Unique identifier for the group on the system/platform. @@ -8011,7 +9116,7 @@ type: keyword -- -*`group.name`*:: +*`host.user.group.name`*:: + -- Name of the group. @@ -8020,2086 +9125,2148 @@ type: keyword -- -[float] -=== hash - -The hash fields represent different hash algorithms and their values. -Field names for common hashes (e.g. MD5, SHA1) are predefined. Add fields for other hashes by lowercasing the hash algorithm name and using underscore separators as appropriate (snake case, e.g. sha3_512). - - -*`hash.md5`*:: +*`host.user.hash`*:: + -- -MD5 hash. +Unique user hash to correlate information for a user in anonymized form. +Useful if `user.id` or `user.name` contain confidential information and cannot be used. type: keyword -- -*`hash.sha1`*:: +*`host.user.id`*:: + -- -SHA1 hash. +One or multiple unique identifiers of the user. type: keyword -- -*`hash.sha256`*:: +*`host.user.name`*:: + -- -SHA256 hash. +Short name or login of the user. type: keyword +example: albert + -- -*`hash.sha512`*:: +*`host.user.name.text`*:: + -- -SHA512 hash. - -type: keyword +type: text -- [float] -=== host +=== http -A host is defined as a general computing instance. -ECS host.* fields should be populated with details about the host on which the event happened, or from which the measurement was taken. Host types include hardware, virtual machines, Docker containers, and Kubernetes nodes. +Fields related to HTTP activity. Use the `url` field set to store the url of the request. -*`host.architecture`*:: +*`http.request.body.bytes`*:: + -- -Operating system architecture. +Size in bytes of the request body. -type: keyword +type: long -example: x86_64 +example: 887 + +format: bytes -- -*`host.domain`*:: +*`http.request.body.content`*:: + -- -Name of the domain of which the host is a member. -For example, on Windows this could be the host's Active Directory domain or NetBIOS domain name. For Linux this could be the domain of the host's LDAP provider. +The full HTTP request body. type: keyword -example: CONTOSO +example: Hello world -- -*`host.geo.city_name`*:: +*`http.request.body.content.text`*:: + -- -City name. - -type: keyword - -example: Montreal +type: text -- -*`host.geo.continent_name`*:: +*`http.request.bytes`*:: + -- -Name of the continent. +Total size in bytes of the request (body and headers). -type: keyword +type: long -example: North America +example: 1437 + +format: bytes -- -*`host.geo.country_iso_code`*:: +*`http.request.method`*:: + -- -Country ISO code. +HTTP request method. +The field value must be normalized to lowercase for querying. See the documentation section "Implementing ECS". type: keyword -example: CA +example: get, post, put -- -*`host.geo.country_name`*:: +*`http.request.referrer`*:: + -- -Country name. +Referrer for this HTTP request. type: keyword -example: Canada +example: https://blog.example.com/ -- -*`host.geo.location`*:: +*`http.response.body.bytes`*:: + -- -Longitude and latitude. +Size in bytes of the response body. -type: geo_point +type: long -example: { "lon": -73.614830, "lat": 45.505918 } +example: 887 + +format: bytes -- -*`host.geo.name`*:: +*`http.response.body.content`*:: + -- -User-defined description of a location, at the level of granularity they care about. -Could be the name of their data centers, the floor number, if this describes a local physical entity, city names. -Not typically used in automated geolocation. +The full HTTP response body. type: keyword -example: boston-dc +example: Hello world -- -*`host.geo.region_iso_code`*:: +*`http.response.body.content.text`*:: + -- -Region ISO code. +type: text -type: keyword +-- -example: CA-QC +*`http.response.bytes`*:: ++ +-- +Total size in bytes of the response (body and headers). + +type: long + +example: 1437 + +format: bytes -- -*`host.geo.region_name`*:: +*`http.response.status_code`*:: + -- -Region name. +HTTP response status code. -type: keyword +type: long -example: Quebec +example: 404 + +format: string -- -*`host.hostname`*:: +*`http.version`*:: + -- -Hostname of the host. -It normally contains what the `hostname` command returns on the host machine. +HTTP version. type: keyword +example: 1.1 + -- -*`host.id`*:: +[float] +=== log + +Details about the event's logging mechanism or logging transport. +The log.* fields are typically populated with details about the logging mechanism used to create and/or transport the event. For example, syslog details belong under `log.syslog.*`. +The details specific to your event source are typically not logged under `log.*`, but rather in `event.*` or in other ECS fields. + + +*`log.level`*:: + -- -Unique host id. -As hostname is not always unique, use values that are meaningful in your environment. -Example: The current usage of `beat.name`. +Original log level of the log event. +If the source of the event provides a log level or textual severity, this is the one that goes in `log.level`. If your source doesn't specify one, you may put your event transport's severity here (e.g. Syslog severity). +Some examples are `warn`, `err`, `i`, `informational`. type: keyword +example: error + -- -*`host.ip`*:: +*`log.logger`*:: + -- -Host ip address. +The name of the logger inside an application. This is usually the name of the class which initialized the logger, or can be a custom name. -type: ip +type: keyword + +example: org.elasticsearch.bootstrap.Bootstrap -- -*`host.mac`*:: +*`log.origin.file.line`*:: + -- -Host mac address. +The line number of the file containing the source code which originated the log event. -type: keyword +type: integer + +example: 42 -- -*`host.name`*:: +*`log.origin.file.name`*:: + -- -Name of the host. -It can contain what `hostname` returns on Unix systems, the fully qualified domain name, or a name specified by the user. The sender decides which value to use. +The name of the file containing the source code which originated the log event. Note that this is not the name of the log file. type: keyword +example: Bootstrap.java + -- -*`host.os.family`*:: +*`log.origin.function`*:: + -- -OS family (such as redhat, debian, freebsd, windows). +The name of the function or method which originated the log event. type: keyword -example: debian +example: init -- -*`host.os.full`*:: +*`log.original`*:: + -- -Operating system name, including the version or code name. +This is the original log message and contains the full log message before splitting it up in multiple parts. +In contrast to the `message` field which can contain an extracted part of the log message, this field contains the original, full log message. It can have already some modifications applied like encoding or new lines removed to clean up the log message. +This field is not indexed and doc_values are disabled so it can't be queried but the value can be retrieved from `_source`. type: keyword -example: Mac OS Mojave +example: Sep 19 08:26:10 localhost My log -- -*`host.os.full.text`*:: +*`log.syslog`*:: + -- -type: text +The Syslog metadata of the event, if the event was transmitted via Syslog. Please see RFCs 5424 or 3164. + +type: object -- -*`host.os.kernel`*:: +*`log.syslog.facility.code`*:: + -- -Operating system kernel version as a raw string. +The Syslog numeric facility of the log event, if available. +According to RFCs 5424 and 3164, this value should be an integer between 0 and 23. -type: keyword +type: long -example: 4.4.0-112-generic +example: 23 + +format: string -- -*`host.os.name`*:: +*`log.syslog.facility.name`*:: + -- -Operating system name, without the version. +The Syslog text-based facility of the log event, if available. type: keyword -example: Mac OS X +example: local7 -- -*`host.os.name.text`*:: +*`log.syslog.priority`*:: + -- -type: text +Syslog numeric priority of the event, if available. +According to RFCs 5424 and 3164, the priority is 8 * facility + severity. This number is therefore expected to contain a value between 0 and 191. + +type: long + +example: 135 + +format: string -- -*`host.os.platform`*:: +*`log.syslog.severity.code`*:: + -- -Operating system platform (such centos, ubuntu, windows). +The Syslog numeric severity of the log event, if available. +If the event source publishing via Syslog provides a different numeric severity value (e.g. firewall, IDS), your source's numeric severity should go to `event.severity`. If the event source does not specify a distinct severity, you can optionally copy the Syslog severity to `event.severity`. -type: keyword +type: long -example: darwin +example: 3 -- -*`host.os.version`*:: +*`log.syslog.severity.name`*:: + -- -Operating system version as a raw string. +The Syslog numeric severity of the log event, if available. +If the event source publishing via Syslog provides a different severity value (e.g. firewall, IDS), your source's text severity should go to `log.level`. If the event source does not specify a distinct severity, you can optionally copy the Syslog severity to `log.level`. type: keyword -example: 10.14.1 +example: Error -- -*`host.type`*:: +[float] +=== network + +The network is defined as the communication path over which a host or network event happens. +The network.* fields should be populated with details about the network activity associated with an event. + + +*`network.application`*:: + -- -Type of host. -For Cloud providers this can be the machine type like `t2.medium`. If vm, this could be the container, for example, or other information meaningful in your environment. +A name given to an application level protocol. This can be arbitrarily assigned for things like microservices, but also apply to things like skype, icq, facebook, twitter. This would be used in situations where the vendor or service can be decoded such as from the source/dest IP owners, ports, or wire format. +The field value must be normalized to lowercase for querying. See the documentation section "Implementing ECS". type: keyword +example: aim + -- -*`host.uptime`*:: +*`network.bytes`*:: + -- -Seconds the host has been up. +Total bytes transferred in both directions. +If `source.bytes` and `destination.bytes` are known, `network.bytes` is their sum. type: long -example: 1325 +example: 368 + +format: bytes -- -*`host.user.domain`*:: +*`network.community_id`*:: + -- -Name of the directory the user is a member of. -For example, an LDAP or Active Directory domain name. +A hash of source and destination IPs and ports, as well as the protocol used in a communication. This is a tool-agnostic standard to identify flows. +Learn more at https://github.com/corelight/community-id-spec. type: keyword +example: 1:hO+sN4H+MG5MY/8hIrXPqc4ZQz0= + -- -*`host.user.email`*:: +*`network.direction`*:: + -- -User email address. +Direction of the network traffic. +Recommended values are: + * inbound + * outbound + * internal + * external + * unknown + +When mapping events from a host-based monitoring context, populate this field from the host's point of view. +When mapping events from a network or perimeter-based monitoring context, populate this field from the point of view of your network perimeter. type: keyword +example: inbound + -- -*`host.user.full_name`*:: +*`network.forwarded_ip`*:: + -- -User's full name, if available. +Host IP address when the source IP address is the proxy. -type: keyword +type: ip -example: Albert Einstein +example: 192.1.1.2 -- -*`host.user.full_name.text`*:: +*`network.iana_number`*:: + -- -type: text +IANA Protocol Number (https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml). Standardized list of protocols. This aligns well with NetFlow and sFlow related logs which use the IANA Protocol Number. + +type: keyword + +example: 6 -- -*`host.user.group.domain`*:: +*`network.name`*:: + -- -Name of the directory the group is a member of. -For example, an LDAP or Active Directory domain name. +Name given by operators to sections of their network. type: keyword +example: Guest Wifi + -- -*`host.user.group.id`*:: +*`network.packets`*:: + -- -Unique identifier for the group on the system/platform. +Total packets transferred in both directions. +If `source.packets` and `destination.packets` are known, `network.packets` is their sum. -type: keyword +type: long + +example: 24 -- -*`host.user.group.name`*:: +*`network.protocol`*:: + -- -Name of the group. +L7 Network protocol name. ex. http, lumberjack, transport protocol. +The field value must be normalized to lowercase for querying. See the documentation section "Implementing ECS". type: keyword +example: http + -- -*`host.user.hash`*:: +*`network.transport`*:: + -- -Unique user hash to correlate information for a user in anonymized form. -Useful if `user.id` or `user.name` contain confidential information and cannot be used. +Same as network.iana_number, but instead using the Keyword name of the transport layer (udp, tcp, ipv6-icmp, etc.) +The field value must be normalized to lowercase for querying. See the documentation section "Implementing ECS". type: keyword +example: tcp + -- -*`host.user.id`*:: +*`network.type`*:: + -- -One or multiple unique identifiers of the user. +In the OSI Model this would be the Network Layer. ipv4, ipv6, ipsec, pim, etc +The field value must be normalized to lowercase for querying. See the documentation section "Implementing ECS". type: keyword +example: ipv4 + -- -*`host.user.name`*:: +[float] +=== observer + +An observer is defined as a special network, security, or application device used to detect, observe, or create network, security, or application-related events and metrics. +This could be a custom hardware appliance or a server that has been configured to run special network, security, or application software. Examples include firewalls, web proxies, intrusion detection/prevention systems, network monitoring sensors, web application firewalls, data loss prevention systems, and APM servers. The observer.* fields shall be populated with details of the system, if any, that detects, observes and/or creates a network, security, or application event or metric. Message queues and ETL components used in processing events or metrics are not considered observers in ECS. + + +*`observer.geo.city_name`*:: + -- -Short name or login of the user. +City name. type: keyword -example: albert +example: Montreal -- -*`host.user.name.text`*:: +*`observer.geo.continent_name`*:: + -- -type: text - --- +Name of the continent. -[float] -=== http +type: keyword -Fields related to HTTP activity. Use the `url` field set to store the url of the request. +example: North America +-- -*`http.request.body.bytes`*:: +*`observer.geo.country_iso_code`*:: + -- -Size in bytes of the request body. - -type: long +Country ISO code. -example: 887 +type: keyword -format: bytes +example: CA -- -*`http.request.body.content`*:: +*`observer.geo.country_name`*:: + -- -The full HTTP request body. +Country name. type: keyword -example: Hello world +example: Canada -- -*`http.request.body.content.text`*:: +*`observer.geo.location`*:: + -- -type: text +Longitude and latitude. + +type: geo_point + +example: { "lon": -73.614830, "lat": 45.505918 } -- -*`http.request.bytes`*:: +*`observer.geo.name`*:: + -- -Total size in bytes of the request (body and headers). - -type: long +User-defined description of a location, at the level of granularity they care about. +Could be the name of their data centers, the floor number, if this describes a local physical entity, city names. +Not typically used in automated geolocation. -example: 1437 +type: keyword -format: bytes +example: boston-dc -- -*`http.request.method`*:: +*`observer.geo.region_iso_code`*:: + -- -HTTP request method. -The field value must be normalized to lowercase for querying. See the documentation section "Implementing ECS". +Region ISO code. type: keyword -example: get, post, put +example: CA-QC -- -*`http.request.referrer`*:: +*`observer.geo.region_name`*:: + -- -Referrer for this HTTP request. +Region name. type: keyword -example: https://blog.example.com/ +example: Quebec -- -*`http.response.body.bytes`*:: +*`observer.hostname`*:: + -- -Size in bytes of the response body. - -type: long - -example: 887 +Hostname of the observer. -format: bytes +type: keyword -- -*`http.response.body.content`*:: +*`observer.ip`*:: + -- -The full HTTP response body. - -type: keyword +IP address of the observer. -example: Hello world +type: ip -- -*`http.response.body.content.text`*:: +*`observer.mac`*:: + -- -type: text +MAC address of the observer + +type: keyword -- -*`http.response.bytes`*:: +*`observer.name`*:: + -- -Total size in bytes of the response (body and headers). - -type: long +Custom name of the observer. +This is a name that can be given to an observer. This can be helpful for example if multiple firewalls of the same model are used in an organization. +If no custom name is needed, the field can be left empty. -example: 1437 +type: keyword -format: bytes +example: 1_proxySG -- -*`http.response.status_code`*:: +*`observer.os.family`*:: + -- -HTTP response status code. - -type: long +OS family (such as redhat, debian, freebsd, windows). -example: 404 +type: keyword -format: string +example: debian -- -*`http.version`*:: +*`observer.os.full`*:: + -- -HTTP version. +Operating system name, including the version or code name. type: keyword -example: 1.1 +example: Mac OS Mojave -- -[float] -=== log - -Details about the event's logging mechanism or logging transport. -The log.* fields are typically populated with details about the logging mechanism used to create and/or transport the event. For example, syslog details belong under `log.syslog.*`. -The details specific to your event source are typically not logged under `log.*`, but rather in `event.*` or in other ECS fields. +*`observer.os.full.text`*:: ++ +-- +type: text +-- -*`log.level`*:: +*`observer.os.kernel`*:: + -- -Original log level of the log event. -If the source of the event provides a log level or textual severity, this is the one that goes in `log.level`. If your source doesn't specify one, you may put your event transport's severity here (e.g. Syslog severity). -Some examples are `warn`, `err`, `i`, `informational`. +Operating system kernel version as a raw string. type: keyword -example: error +example: 4.4.0-112-generic -- -*`log.logger`*:: +*`observer.os.name`*:: + -- -The name of the logger inside an application. This is usually the name of the class which initialized the logger, or can be a custom name. +Operating system name, without the version. type: keyword -example: org.elasticsearch.bootstrap.Bootstrap +example: Mac OS X -- -*`log.origin.file.line`*:: +*`observer.os.name.text`*:: + -- -The line number of the file containing the source code which originated the log event. - -type: integer - -example: 42 +type: text -- -*`log.origin.file.name`*:: +*`observer.os.platform`*:: + -- -The name of the file containing the source code which originated the log event. Note that this is not the name of the log file. +Operating system platform (such centos, ubuntu, windows). type: keyword -example: Bootstrap.java +example: darwin -- -*`log.origin.function`*:: +*`observer.os.version`*:: + -- -The name of the function or method which originated the log event. +Operating system version as a raw string. type: keyword -example: init +example: 10.14.1 -- -*`log.original`*:: +*`observer.product`*:: + -- -This is the original log message and contains the full log message before splitting it up in multiple parts. -In contrast to the `message` field which can contain an extracted part of the log message, this field contains the original, full log message. It can have already some modifications applied like encoding or new lines removed to clean up the log message. -This field is not indexed and doc_values are disabled so it can't be queried but the value can be retrieved from `_source`. +The product name of the observer. type: keyword -example: Sep 19 08:26:10 localhost My log +example: s200 -- -*`log.syslog`*:: +*`observer.serial_number`*:: + -- -The Syslog metadata of the event, if the event was transmitted via Syslog. Please see RFCs 5424 or 3164. +Observer serial number. -type: object +type: keyword -- -*`log.syslog.facility.code`*:: +*`observer.type`*:: + -- -The Syslog numeric facility of the log event, if available. -According to RFCs 5424 and 3164, this value should be an integer between 0 and 23. - -type: long +The type of the observer the data is coming from. +There is no predefined list of observer types. Some examples are `forwarder`, `firewall`, `ids`, `ips`, `proxy`, `poller`, `sensor`, `APM server`. -example: 23 +type: keyword -format: string +example: firewall -- -*`log.syslog.facility.name`*:: +*`observer.vendor`*:: + -- -The Syslog text-based facility of the log event, if available. +Vendor name of the observer. type: keyword -example: local7 +example: Symantec -- -*`log.syslog.priority`*:: +*`observer.version`*:: + -- -Syslog numeric priority of the event, if available. -According to RFCs 5424 and 3164, the priority is 8 * facility + severity. This number is therefore expected to contain a value between 0 and 191. +Observer version. -type: long +type: keyword -example: 135 +-- -format: string +[float] +=== organization --- +The organization fields enrich data with information about the company or entity the data is associated with. +These fields help you arrange or filter data stored in an index by one or multiple organizations. -*`log.syslog.severity.code`*:: + +*`organization.id`*:: + -- -The Syslog numeric severity of the log event, if available. -If the event source publishing via Syslog provides a different numeric severity value (e.g. firewall, IDS), your source's numeric severity should go to `event.severity`. If the event source does not specify a distinct severity, you can optionally copy the Syslog severity to `event.severity`. - -type: long +Unique identifier for the organization. -example: 3 +type: keyword -- -*`log.syslog.severity.name`*:: +*`organization.name`*:: + -- -The Syslog numeric severity of the log event, if available. -If the event source publishing via Syslog provides a different severity value (e.g. firewall, IDS), your source's text severity should go to `log.level`. If the event source does not specify a distinct severity, you can optionally copy the Syslog severity to `log.level`. +Organization name. type: keyword -example: Error +-- + +*`organization.name.text`*:: ++ +-- +type: text -- [float] -=== network +=== os -The network is defined as the communication path over which a host or network event happens. -The network.* fields should be populated with details about the network activity associated with an event. +The OS fields contain information about the operating system. -*`network.application`*:: +*`os.family`*:: + -- -A name given to an application level protocol. This can be arbitrarily assigned for things like microservices, but also apply to things like skype, icq, facebook, twitter. This would be used in situations where the vendor or service can be decoded such as from the source/dest IP owners, ports, or wire format. -The field value must be normalized to lowercase for querying. See the documentation section "Implementing ECS". +OS family (such as redhat, debian, freebsd, windows). type: keyword -example: aim +example: debian -- -*`network.bytes`*:: +*`os.full`*:: + -- -Total bytes transferred in both directions. -If `source.bytes` and `destination.bytes` are known, `network.bytes` is their sum. +Operating system name, including the version or code name. -type: long +type: keyword -example: 368 +example: Mac OS Mojave -format: bytes +-- +*`os.full.text`*:: ++ -- +type: text -*`network.community_id`*:: +-- + +*`os.kernel`*:: + -- -A hash of source and destination IPs and ports, as well as the protocol used in a communication. This is a tool-agnostic standard to identify flows. -Learn more at https://github.com/corelight/community-id-spec. +Operating system kernel version as a raw string. type: keyword -example: 1:hO+sN4H+MG5MY/8hIrXPqc4ZQz0= +example: 4.4.0-112-generic -- -*`network.direction`*:: +*`os.name`*:: + -- -Direction of the network traffic. -Recommended values are: - * inbound - * outbound - * internal - * external - * unknown - -When mapping events from a host-based monitoring context, populate this field from the host's point of view. -When mapping events from a network or perimeter-based monitoring context, populate this field from the point of view of your network perimeter. +Operating system name, without the version. type: keyword -example: inbound +example: Mac OS X -- -*`network.forwarded_ip`*:: +*`os.name.text`*:: + -- -Host IP address when the source IP address is the proxy. - -type: ip - -example: 192.1.1.2 +type: text -- -*`network.iana_number`*:: +*`os.platform`*:: + -- -IANA Protocol Number (https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml). Standardized list of protocols. This aligns well with NetFlow and sFlow related logs which use the IANA Protocol Number. +Operating system platform (such centos, ubuntu, windows). type: keyword -example: 6 +example: darwin -- -*`network.name`*:: +*`os.version`*:: + -- -Name given by operators to sections of their network. +Operating system version as a raw string. type: keyword -example: Guest Wifi +example: 10.14.1 -- -*`network.packets`*:: +[float] +=== package + +These fields contain information about an installed software package. It contains general information about a package, such as name, version or size. It also contains installation details, such as time or location. + + +*`package.architecture`*:: + -- -Total packets transferred in both directions. -If `source.packets` and `destination.packets` are known, `network.packets` is their sum. +Package architecture. -type: long +type: keyword -example: 24 +example: x86_64 -- -*`network.protocol`*:: +*`package.build_version`*:: + -- -L7 Network protocol name. ex. http, lumberjack, transport protocol. -The field value must be normalized to lowercase for querying. See the documentation section "Implementing ECS". +Additional information about the build version of the installed package. +For example use the commit SHA of a non-released package. type: keyword -example: http +example: 36f4f7e89dd61b0988b12ee000b98966867710cd -- -*`network.transport`*:: +*`package.checksum`*:: + -- -Same as network.iana_number, but instead using the Keyword name of the transport layer (udp, tcp, ipv6-icmp, etc.) -The field value must be normalized to lowercase for querying. See the documentation section "Implementing ECS". +Checksum of the installed package for verification. type: keyword -example: tcp +example: 68b329da9893e34099c7d8ad5cb9c940 -- -*`network.type`*:: +*`package.description`*:: + -- -In the OSI Model this would be the Network Layer. ipv4, ipv6, ipsec, pim, etc -The field value must be normalized to lowercase for querying. See the documentation section "Implementing ECS". +Description of the package. type: keyword -example: ipv4 +example: Open source programming language to build simple/reliable/efficient software. -- -[float] -=== observer +*`package.install_scope`*:: ++ +-- +Indicating how the package was installed, e.g. user-local, global. -An observer is defined as a special network, security, or application device used to detect, observe, or create network, security, or application-related events and metrics. -This could be a custom hardware appliance or a server that has been configured to run special network, security, or application software. Examples include firewalls, web proxies, intrusion detection/prevention systems, network monitoring sensors, web application firewalls, data loss prevention systems, and APM servers. The observer.* fields shall be populated with details of the system, if any, that detects, observes and/or creates a network, security, or application event or metric. Message queues and ETL components used in processing events or metrics are not considered observers in ECS. +type: keyword +example: global -*`observer.geo.city_name`*:: -+ -- -City name. -type: keyword +*`package.installed`*:: ++ +-- +Time when package was installed. -example: Montreal +type: date -- -*`observer.geo.continent_name`*:: +*`package.license`*:: + -- -Name of the continent. +License under which the package was released. +Use a short name, e.g. the license identifier from SPDX License List where possible (https://spdx.org/licenses/). type: keyword -example: North America +example: Apache License 2.0 -- -*`observer.geo.country_iso_code`*:: +*`package.name`*:: + -- -Country ISO code. +Package name type: keyword -example: CA +example: go -- -*`observer.geo.country_name`*:: +*`package.path`*:: + -- -Country name. +Path where the package is installed. type: keyword -example: Canada +example: /usr/local/Cellar/go/1.12.9/ -- -*`observer.geo.location`*:: +*`package.reference`*:: + -- -Longitude and latitude. +Home page or reference URL of the software in this package, if available. -type: geo_point +type: keyword -example: { "lon": -73.614830, "lat": 45.505918 } +example: https://golang.org -- -*`observer.geo.name`*:: +*`package.size`*:: + -- -User-defined description of a location, at the level of granularity they care about. -Could be the name of their data centers, the floor number, if this describes a local physical entity, city names. -Not typically used in automated geolocation. +Package size in bytes. -type: keyword +type: long + +example: 62231 -example: boston-dc +format: string -- -*`observer.geo.region_iso_code`*:: +*`package.type`*:: + -- -Region ISO code. +Type of package. +This should contain the package file type, rather than the package manager name. Examples: rpm, dpkg, brew, npm, gem, nupkg, jar. type: keyword -example: CA-QC +example: rpm -- -*`observer.geo.region_name`*:: +*`package.version`*:: + -- -Region name. +Package version type: keyword -example: Quebec +example: 1.12.9 -- -*`observer.hostname`*:: -+ --- -Hostname of the observer. +[float] +=== process -type: keyword +These fields contain information about a process. +These fields can help you correlate metrics information with a process id/name from a log message. The `process.pid` often stays in the metric itself and is copied to the global field for correlation. --- -*`observer.ip`*:: +*`process.args`*:: + -- -IP address of the observer. +Array of process arguments, starting with the absolute path to the executable. +May be filtered to protect sensitive information. -type: ip +type: keyword + +example: ['/usr/bin/ssh', '-l', 'user', '10.0.0.16'] -- -*`observer.mac`*:: +*`process.args_count`*:: + -- -MAC address of the observer +Length of the process.args array. +This field can be useful for querying or performing bucket analysis on how many arguments were provided to start a process. More arguments may be an indication of suspicious activity. -type: keyword +type: long + +example: 4 -- -*`observer.name`*:: +*`process.command_line`*:: + -- -Custom name of the observer. -This is a name that can be given to an observer. This can be helpful for example if multiple firewalls of the same model are used in an organization. -If no custom name is needed, the field can be left empty. +Full command line that started the process, including the absolute path to the executable, and all arguments. +Some arguments may be filtered to protect sensitive information. type: keyword -example: 1_proxySG +example: /usr/bin/ssh -l user 10.0.0.16 -- -*`observer.os.family`*:: +*`process.command_line.text`*:: + -- -OS family (such as redhat, debian, freebsd, windows). - -type: keyword - -example: debian +type: text -- -*`observer.os.full`*:: +*`process.executable`*:: + -- -Operating system name, including the version or code name. +Absolute path to the process executable. type: keyword -example: Mac OS Mojave +example: /usr/bin/ssh -- -*`observer.os.full.text`*:: +*`process.executable.text`*:: + -- type: text -- -*`observer.os.kernel`*:: +*`process.exit_code`*:: + -- -Operating system kernel version as a raw string. +The exit code of the process, if this is a termination event. +The field should be absent if there is no exit code for the event (e.g. process start). -type: keyword +type: long -example: 4.4.0-112-generic +example: 137 -- -*`observer.os.name`*:: +*`process.hash.md5`*:: + -- -Operating system name, without the version. +MD5 hash. type: keyword -example: Mac OS X - -- -*`observer.os.name.text`*:: +*`process.hash.sha1`*:: + -- -type: text +SHA1 hash. + +type: keyword -- -*`observer.os.platform`*:: +*`process.hash.sha256`*:: + -- -Operating system platform (such centos, ubuntu, windows). +SHA256 hash. type: keyword -example: darwin - -- -*`observer.os.version`*:: +*`process.hash.sha512`*:: + -- -Operating system version as a raw string. +SHA512 hash. type: keyword -example: 10.14.1 - -- -*`observer.product`*:: +*`process.name`*:: + -- -The product name of the observer. +Process name. +Sometimes called program name or similar. type: keyword -example: s200 +example: ssh -- -*`observer.serial_number`*:: +*`process.name.text`*:: + -- -Observer serial number. - -type: keyword +type: text -- -*`observer.type`*:: +*`process.parent.args`*:: + -- -The type of the observer the data is coming from. -There is no predefined list of observer types. Some examples are `forwarder`, `firewall`, `ids`, `ips`, `proxy`, `poller`, `sensor`, `APM server`. +Array of process arguments. +May be filtered to protect sensitive information. type: keyword -example: firewall +example: ['ssh', '-l', 'user', '10.0.0.16'] -- -*`observer.vendor`*:: +*`process.parent.args_count`*:: + -- -Vendor name of the observer. +Length of the process.args array. +This field can be useful for querying or performing bucket analysis on how many arguments were provided to start a process. More arguments may be an indication of suspicious activity. -type: keyword +type: long -example: Symantec +example: 4 -- -*`observer.version`*:: +*`process.parent.command_line`*:: + -- -Observer version. +Full command line that started the process, including the absolute path to the executable, and all arguments. +Some arguments may be filtered to protect sensitive information. type: keyword --- - -[float] -=== organization - -The organization fields enrich data with information about the company or entity the data is associated with. -These fields help you arrange or filter data stored in an index by one or multiple organizations. +example: /usr/bin/ssh -l user 10.0.0.16 +-- -*`organization.id`*:: +*`process.parent.command_line.text`*:: + -- -Unique identifier for the organization. - -type: keyword +type: text -- -*`organization.name`*:: +*`process.parent.executable`*:: + -- -Organization name. +Absolute path to the process executable. type: keyword +example: /usr/bin/ssh + -- -*`organization.name.text`*:: +*`process.parent.executable.text`*:: + -- type: text -- -[float] -=== os - -The OS fields contain information about the operating system. - - -*`os.family`*:: +*`process.parent.exit_code`*:: + -- -OS family (such as redhat, debian, freebsd, windows). +The exit code of the process, if this is a termination event. +The field should be absent if there is no exit code for the event (e.g. process start). -type: keyword +type: long -example: debian +example: 137 -- -*`os.full`*:: +*`process.parent.name`*:: + -- -Operating system name, including the version or code name. +Process name. +Sometimes called program name or similar. type: keyword -example: Mac OS Mojave +example: ssh -- -*`os.full.text`*:: +*`process.parent.name.text`*:: + -- type: text -- -*`os.kernel`*:: +*`process.parent.pgid`*:: + -- -Operating system kernel version as a raw string. +Identifier of the group of processes the process belongs to. -type: keyword +type: long -example: 4.4.0-112-generic +format: string -- -*`os.name`*:: +*`process.parent.pid`*:: + -- -Operating system name, without the version. +Process id. -type: keyword +type: long -example: Mac OS X +example: 4242 + +format: string -- -*`os.name.text`*:: +*`process.parent.ppid`*:: + -- -type: text +Parent process' pid. + +type: long + +example: 4241 + +format: string -- -*`os.platform`*:: +*`process.parent.start`*:: + -- -Operating system platform (such centos, ubuntu, windows). +The time the process started. -type: keyword +type: date -example: darwin +example: 2016-05-23T08:05:34.853Z -- -*`os.version`*:: +*`process.parent.thread.id`*:: + -- -Operating system version as a raw string. - -type: keyword - -example: 10.14.1 +Thread ID. --- +type: long -[float] -=== package +example: 4242 -These fields contain information about an installed software package. It contains general information about a package, such as name, version or size. It also contains installation details, such as time or location. +format: string +-- -*`package.architecture`*:: +*`process.parent.thread.name`*:: + -- -Package architecture. +Thread name. type: keyword -example: x86_64 +example: thread-0 -- -*`package.build_version`*:: +*`process.parent.title`*:: + -- -Additional information about the build version of the installed package. -For example use the commit SHA of a non-released package. +Process title. +The proctitle, some times the same as process name. Can also be different: for example a browser setting its title to the web page currently opened. type: keyword -example: 36f4f7e89dd61b0988b12ee000b98966867710cd - -- -*`package.checksum`*:: +*`process.parent.title.text`*:: + -- -Checksum of the installed package for verification. - -type: keyword - -example: 68b329da9893e34099c7d8ad5cb9c940 +type: text -- -*`package.description`*:: +*`process.parent.uptime`*:: + -- -Description of the package. +Seconds the process has been up. -type: keyword +type: long -example: Open source programming language to build simple/reliable/efficient software. +example: 1325 -- -*`package.install_scope`*:: +*`process.parent.working_directory`*:: + -- -Indicating how the package was installed, e.g. user-local, global. +The working directory of the process. type: keyword -example: global +example: /home/alice -- -*`package.installed`*:: +*`process.parent.working_directory.text`*:: + -- -Time when package was installed. - -type: date +type: text -- -*`package.license`*:: +*`process.pgid`*:: + -- -License under which the package was released. -Use a short name, e.g. the license identifier from SPDX License List where possible (https://spdx.org/licenses/). +Identifier of the group of processes the process belongs to. -type: keyword +type: long -example: Apache License 2.0 +format: string -- -*`package.name`*:: +*`process.pid`*:: + -- -Package name +Process id. -type: keyword +type: long -example: go +example: 4242 + +format: string -- -*`package.path`*:: +*`process.ppid`*:: + -- -Path where the package is installed. +Parent process' pid. -type: keyword +type: long -example: /usr/local/Cellar/go/1.12.9/ +example: 4241 + +format: string -- -*`package.reference`*:: +*`process.start`*:: + -- -Home page or reference URL of the software in this package, if available. +The time the process started. -type: keyword +type: date -example: https://golang.org +example: 2016-05-23T08:05:34.853Z -- -*`package.size`*:: +*`process.thread.id`*:: + -- -Package size in bytes. +Thread ID. type: long -example: 62231 +example: 4242 format: string -- -*`package.type`*:: +*`process.thread.name`*:: + -- -Type of package. -This should contain the package file type, rather than the package manager name. Examples: rpm, dpkg, brew, npm, gem, nupkg, jar. +Thread name. type: keyword -example: rpm +example: thread-0 -- -*`package.version`*:: +*`process.title`*:: + -- -Package version +Process title. +The proctitle, some times the same as process name. Can also be different: for example a browser setting its title to the web page currently opened. type: keyword -example: 1.12.9 - -- -[float] -=== process - -These fields contain information about a process. -These fields can help you correlate metrics information with a process id/name from a log message. The `process.pid` often stays in the metric itself and is copied to the global field for correlation. - - -*`process.args`*:: +*`process.title.text`*:: + -- -Array of process arguments, starting with the absolute path to the executable. -May be filtered to protect sensitive information. - -type: keyword - -example: ['/usr/bin/ssh', '-l', 'user', '10.0.0.16'] +type: text -- -*`process.args_count`*:: +*`process.uptime`*:: + -- -Length of the process.args array. -This field can be useful for querying or performing bucket analysis on how many arguments were provided to start a process. More arguments may be an indication of suspicious activity. +Seconds the process has been up. type: long -example: 4 +example: 1325 -- -*`process.command_line`*:: +*`process.working_directory`*:: + -- -Full command line that started the process, including the absolute path to the executable, and all arguments. -Some arguments may be filtered to protect sensitive information. +The working directory of the process. type: keyword -example: /usr/bin/ssh -l user 10.0.0.16 +example: /home/alice -- -*`process.command_line.text`*:: +*`process.working_directory.text`*:: + -- type: text -- -*`process.executable`*:: +[float] +=== registry + +Fields related to Windows Registry operations. + + +*`registry.data.bytes`*:: + -- -Absolute path to the process executable. +Original bytes written with base64 encoding. +For Windows registry operations, such as SetValueEx and RegQueryValueEx, this corresponds to the data pointed by `lp_data`. This is optional but provides better recoverability and should be populated for REG_BINARY encoded values. type: keyword -example: /usr/bin/ssh +example: ZQBuAC0AVQBTAAAAZQBuAAAAAAA= -- -*`process.executable.text`*:: +*`registry.data.strings`*:: + -- -type: text +Content when writing string types. +Populated as an array when writing string data to the registry. For single string registry types (REG_SZ, REG_EXPAND_SZ), this should be an array with one string. For sequences of string with REG_MULTI_SZ, this array will be variable length. For numeric data, such as REG_DWORD and REG_QWORD, this should be populated with the decimal representation (e.g `"1"`). + +type: keyword + +example: ["C:\rta\red_ttp\bin\myapp.exe"] -- -*`process.exit_code`*:: +*`registry.data.type`*:: + -- -The exit code of the process, if this is a termination event. -The field should be absent if there is no exit code for the event (e.g. process start). +Standard registry type for encoding contents -type: long +type: keyword -example: 137 +example: REG_SZ -- -*`process.hash.md5`*:: +*`registry.hive`*:: + -- -MD5 hash. +Abbreviated name for the hive. type: keyword +example: HKLM + -- -*`process.hash.sha1`*:: +*`registry.key`*:: + -- -SHA1 hash. +Hive-relative path of keys. type: keyword +example: SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\winword.exe + -- -*`process.hash.sha256`*:: +*`registry.path`*:: + -- -SHA256 hash. +Full path, including hive, key and value type: keyword +example: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\winword.exe\Debugger + -- -*`process.hash.sha512`*:: +*`registry.value`*:: + -- -SHA512 hash. +Name of the value written. type: keyword +example: Debugger + -- -*`process.name`*:: +[float] +=== related + +This field set is meant to facilitate pivoting around a piece of data. +Some pieces of information can be seen in many places in an ECS event. To facilitate searching for them, store an array of all seen values to their corresponding field in `related.`. +A concrete example is IP addresses, which can be under host, observer, source, destination, client, server, and network.forwarded_ip. If you append all IPs to `related.ip`, you can then search for a given IP trivially, no matter where it appeared, by querying `related.ip:a.b.c.d`. + + +*`related.ip`*:: + -- -Process name. -Sometimes called program name or similar. - -type: keyword +All of the IPs seen on your event. -example: ssh +type: ip -- -*`process.name.text`*:: +*`related.user`*:: + -- -type: text +All the user names seen on your event. + +type: keyword -- -*`process.parent.args`*:: +[float] +=== rule + +Rule fields are used to capture the specifics of any observer or agent rules that generate alerts or other notable events. +Examples of data sources that would populate the rule fields include: network admission control platforms, network or host IDS/IPS, network firewalls, web application firewalls, url filters, endpoint detection and response (EDR) systems, etc. + + +*`rule.category`*:: + -- -Array of process arguments. -May be filtered to protect sensitive information. +A categorization value keyword used by the entity using the rule for detection of this event. type: keyword -example: ['ssh', '-l', 'user', '10.0.0.16'] +example: Attempted Information Leak -- -*`process.parent.args_count`*:: +*`rule.description`*:: + -- -Length of the process.args array. -This field can be useful for querying or performing bucket analysis on how many arguments were provided to start a process. More arguments may be an indication of suspicious activity. +The description of the rule generating the event. -type: long +type: keyword -example: 4 +example: Block requests to public DNS over HTTPS / TLS protocols -- -*`process.parent.command_line`*:: +*`rule.id`*:: + -- -Full command line that started the process, including the absolute path to the executable, and all arguments. -Some arguments may be filtered to protect sensitive information. +A rule ID that is unique within the scope of an agent, observer, or other entity using the rule for detection of this event. type: keyword -example: /usr/bin/ssh -l user 10.0.0.16 +example: 101 -- -*`process.parent.command_line.text`*:: +*`rule.name`*:: + -- -type: text +The name of the rule or signature generating the event. + +type: keyword + +example: BLOCK_DNS_over_TLS -- -*`process.parent.executable`*:: +*`rule.reference`*:: + -- -Absolute path to the process executable. +Reference URL to additional information about the rule used to generate this event. +The URL can point to the vendor's documentation about the rule. If that's not available, it can also be a link to a more general page describing this type of alert. type: keyword -example: /usr/bin/ssh +example: https://en.wikipedia.org/wiki/DNS_over_TLS -- -*`process.parent.executable.text`*:: +*`rule.ruleset`*:: + -- -type: text +Name of the ruleset, policy, group, or parent category in which the rule used to generate this event is a member. + +type: keyword + +example: Standard_Protocol_Filters -- -*`process.parent.exit_code`*:: +*`rule.uuid`*:: + -- -The exit code of the process, if this is a termination event. -The field should be absent if there is no exit code for the event (e.g. process start). +A rule ID that is unique within the scope of a set or group of agents, observers, or other entities using the rule for detection of this event. -type: long +type: keyword -example: 137 +example: 1100110011 -- -*`process.parent.name`*:: +*`rule.version`*:: + -- -Process name. -Sometimes called program name or similar. +The version / revision of the rule being used for analysis. type: keyword -example: ssh +example: 1.1 -- -*`process.parent.name.text`*:: -+ --- -type: text +[float] +=== server --- +A Server is defined as the responder in a network connection for events regarding sessions, connections, or bidirectional flow records. +For TCP events, the server is the receiver of the initial SYN packet(s) of the TCP connection. For other protocols, the server is generally the responder in the network transaction. Some systems actually use the term "responder" to refer the server in TCP connections. The server fields describe details about the system acting as the server in the network event. Server fields are usually populated in conjunction with client fields. Server fields are generally not populated for packet-level events. +Client / server representations can add semantic context to an exchange, which is helpful to visualize the data in certain situations. If your context falls in that category, you should still ensure that source and destination are filled appropriately. -*`process.parent.pgid`*:: + +*`server.address`*:: + -- -Identifier of the group of processes the process belongs to. - -type: long +Some event server addresses are defined ambiguously. The event will sometimes list an IP, a domain or a unix socket. You should always store the raw address in the `.address` field. +Then it should be duplicated to `.ip` or `.domain`, depending on which one it is. -format: string +type: keyword -- -*`process.parent.pid`*:: +*`server.as.number`*:: + -- -Process id. +Unique number allocated to the autonomous system. The autonomous system number (ASN) uniquely identifies each network on the Internet. type: long -example: 4242 - -format: string +example: 15169 -- -*`process.parent.ppid`*:: +*`server.as.organization.name`*:: + -- -Parent process' pid. - -type: long +Organization name. -example: 4241 +type: keyword -format: string +example: Google LLC -- -*`process.parent.start`*:: +*`server.as.organization.name.text`*:: + -- -The time the process started. - -type: date - -example: 2016-05-23T08:05:34.853Z +type: text -- -*`process.parent.thread.id`*:: +*`server.bytes`*:: + -- -Thread ID. +Bytes sent from the server to the client. type: long -example: 4242 +example: 184 -format: string +format: bytes -- -*`process.parent.thread.name`*:: +*`server.domain`*:: + -- -Thread name. +Server domain. type: keyword -example: thread-0 - -- -*`process.parent.title`*:: +*`server.geo.city_name`*:: + -- -Process title. -The proctitle, some times the same as process name. Can also be different: for example a browser setting its title to the web page currently opened. +City name. type: keyword --- - -*`process.parent.title.text`*:: -+ --- -type: text +example: Montreal -- -*`process.parent.uptime`*:: +*`server.geo.continent_name`*:: + -- -Seconds the process has been up. +Name of the continent. -type: long +type: keyword -example: 1325 +example: North America -- -*`process.parent.working_directory`*:: +*`server.geo.country_iso_code`*:: + -- -The working directory of the process. +Country ISO code. type: keyword -example: /home/alice +example: CA -- -*`process.parent.working_directory.text`*:: +*`server.geo.country_name`*:: + -- -type: text +Country name. + +type: keyword + +example: Canada -- -*`process.pgid`*:: +*`server.geo.location`*:: + -- -Identifier of the group of processes the process belongs to. +Longitude and latitude. -type: long +type: geo_point -format: string +example: { "lon": -73.614830, "lat": 45.505918 } -- -*`process.pid`*:: +*`server.geo.name`*:: + -- -Process id. - -type: long +User-defined description of a location, at the level of granularity they care about. +Could be the name of their data centers, the floor number, if this describes a local physical entity, city names. +Not typically used in automated geolocation. -example: 4242 +type: keyword -format: string +example: boston-dc -- -*`process.ppid`*:: +*`server.geo.region_iso_code`*:: + -- -Parent process' pid. - -type: long +Region ISO code. -example: 4241 +type: keyword -format: string +example: CA-QC -- -*`process.start`*:: +*`server.geo.region_name`*:: + -- -The time the process started. +Region name. -type: date +type: keyword -example: 2016-05-23T08:05:34.853Z +example: Quebec -- -*`process.thread.id`*:: +*`server.ip`*:: + -- -Thread ID. - -type: long - -example: 4242 +IP address of the server. +Can be one or multiple IPv4 or IPv6 addresses. -format: string +type: ip -- -*`process.thread.name`*:: +*`server.mac`*:: + -- -Thread name. +MAC address of the server. type: keyword -example: thread-0 - -- -*`process.title`*:: +*`server.nat.ip`*:: + -- -Process title. -The proctitle, some times the same as process name. Can also be different: for example a browser setting its title to the web page currently opened. +Translated ip of destination based NAT sessions (e.g. internet to private DMZ) +Typically used with load balancers, firewalls, or routers. -type: keyword +type: ip -- -*`process.title.text`*:: +*`server.nat.port`*:: + -- -type: text +Translated port of destination based NAT sessions (e.g. internet to private DMZ) +Typically used with load balancers, firewalls, or routers. + +type: long + +format: string -- -*`process.uptime`*:: +*`server.packets`*:: + -- -Seconds the process has been up. +Packets sent from the server to the client. type: long -example: 1325 +example: 12 -- -*`process.working_directory`*:: +*`server.port`*:: + -- -The working directory of the process. +Port of the server. -type: keyword +type: long -example: /home/alice +format: string -- -*`process.working_directory.text`*:: +*`server.registered_domain`*:: + -- -type: text - --- +The highest registered server domain, stripped of the subdomain. +For example, the registered domain for "foo.google.com" is "google.com". +This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last two labels will not work well for TLDs such as "co.uk". -[float] -=== registry +type: keyword -Fields related to Windows Registry operations. +example: google.com +-- -*`registry.data.bytes`*:: +*`server.top_level_domain`*:: + -- -Original bytes written with base64 encoding. -For Windows registry operations, such as SetValueEx and RegQueryValueEx, this corresponds to the data pointed by `lp_data`. This is optional but provides better recoverability and should be populated for REG_BINARY encoded values. +The effective top level domain (eTLD), also known as the domain suffix, is the last part of the domain name. For example, the top level domain for google.com is "com". +This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last label will not work well for effective TLDs such as "co.uk". type: keyword -example: ZQBuAC0AVQBTAAAAZQBuAAAAAAA= +example: co.uk -- -*`registry.data.strings`*:: +*`server.user.domain`*:: + -- -Content when writing string types. -Populated as an array when writing string data to the registry. For single string registry types (REG_SZ, REG_EXPAND_SZ), this should be an array with one string. For sequences of string with REG_MULTI_SZ, this array will be variable length. For numeric data, such as REG_DWORD and REG_QWORD, this should be populated with the decimal representation (e.g `"1"`). +Name of the directory the user is a member of. +For example, an LDAP or Active Directory domain name. type: keyword -example: ["C:\rta\red_ttp\bin\myapp.exe"] - -- -*`registry.data.type`*:: +*`server.user.email`*:: + -- -Standard registry type for encoding contents +User email address. type: keyword -example: REG_SZ - -- -*`registry.hive`*:: +*`server.user.full_name`*:: + -- -Abbreviated name for the hive. +User's full name, if available. type: keyword -example: HKLM +example: Albert Einstein -- -*`registry.key`*:: +*`server.user.full_name.text`*:: + -- -Hive-relative path of keys. - -type: keyword - -example: SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\winword.exe +type: text -- -*`registry.path`*:: +*`server.user.group.domain`*:: + -- -Full path, including hive, key and value +Name of the directory the group is a member of. +For example, an LDAP or Active Directory domain name. type: keyword -example: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\winword.exe\Debugger - -- -*`registry.value`*:: +*`server.user.group.id`*:: + -- -Name of the value written. +Unique identifier for the group on the system/platform. type: keyword -example: Debugger - -- -[float] -=== related +*`server.user.group.name`*:: ++ +-- +Name of the group. -This field set is meant to facilitate pivoting around a piece of data. -Some pieces of information can be seen in many places in an ECS event. To facilitate searching for them, store an array of all seen values to their corresponding field in `related.`. -A concrete example is IP addresses, which can be under host, observer, source, destination, client, server, and network.forwarded_ip. If you append all IPs to `related.ip`, you can then search for a given IP trivially, no matter where it appeared, by querying `related.ip:a.b.c.d`. +type: keyword +-- -*`related.ip`*:: +*`server.user.hash`*:: + -- -All of the IPs seen on your event. +Unique user hash to correlate information for a user in anonymized form. +Useful if `user.id` or `user.name` contain confidential information and cannot be used. -type: ip +type: keyword -- -*`related.user`*:: +*`server.user.id`*:: + -- -All the user names seen on your event. +One or multiple unique identifiers of the user. type: keyword -- -[float] -=== rule +*`server.user.name`*:: ++ +-- +Short name or login of the user. -Rule fields are used to capture the specifics of any observer or agent rules that generate alerts or other notable events. -Examples of data sources that would populate the rule fields include: network admission control platforms, network or host IDS/IPS, network firewalls, web application firewalls, url filters, endpoint detection and response (EDR) systems, etc. +type: keyword + +example: albert +-- -*`rule.category`*:: +*`server.user.name.text`*:: + -- -A categorization value keyword used by the entity using the rule for detection of this event. +type: text -type: keyword +-- -example: Attempted Information Leak +[float] +=== service --- +The service fields describe the service for or from which the data was collected. +These fields help you find and correlate logs for a specific service and version. -*`rule.description`*:: + +*`service.ephemeral_id`*:: + -- -The description of the rule generating the event. +Ephemeral identifier of this service (if one exists). +This id normally changes across restarts, but `service.id` does not. type: keyword -example: Block requests to public DNS over HTTPS / TLS protocols +example: 8a4f500f -- -*`rule.id`*:: +*`service.id`*:: + -- -A rule ID that is unique within the scope of an agent, observer, or other entity using the rule for detection of this event. +Unique identifier of the running service. If the service is comprised of many nodes, the `service.id` should be the same for all nodes. +This id should uniquely identify the service. This makes it possible to correlate logs and metrics for one specific service, no matter which particular node emitted the event. +Note that if you need to see the events from one specific host of the service, you should filter on that `host.name` or `host.id` instead. type: keyword -example: 101 +example: d37e5ebfe0ae6c4972dbe9f0174a1637bb8247f6 -- -*`rule.name`*:: +*`service.name`*:: + -- -The name of the rule or signature generating the event. +Name of the service data is collected from. +The name of the service is normally user given. This allows for distributed services that run on multiple hosts to correlate the related instances based on the name. +In the case of Elasticsearch the `service.name` could contain the cluster name. For Beats the `service.name` is by default a copy of the `service.type` field if no name is specified. type: keyword -example: BLOCK_DNS_over_TLS +example: elasticsearch-metrics -- -*`rule.reference`*:: +*`service.node.name`*:: + -- -Reference URL to additional information about the rule used to generate this event. -The URL can point to the vendor's documentation about the rule. If that's not available, it can also be a link to a more general page describing this type of alert. +Name of a service node. +This allows for two nodes of the same service running on the same host to be differentiated. Therefore, `service.node.name` should typically be unique across nodes of a given service. +In the case of Elasticsearch, the `service.node.name` could contain the unique node name within the Elasticsearch cluster. In cases where the service doesn't have the concept of a node name, the host name or container name can be used to distinguish running instances that make up this service. If those do not provide uniqueness (e.g. multiple instances of the service running on the same host) - the node name can be manually set. type: keyword -example: https://en.wikipedia.org/wiki/DNS_over_TLS +example: instance-0000000016 -- -*`rule.ruleset`*:: +*`service.state`*:: + -- -Name of the ruleset, policy, group, or parent category in which the rule used to generate this event is a member. +Current state of the service. type: keyword -example: Standard_Protocol_Filters - -- -*`rule.uuid`*:: +*`service.type`*:: + -- -A rule ID that is unique within the scope of a set or group of agents, observers, or other entities using the rule for detection of this event. +The type of the service data is collected from. +The type can be used to group and correlate logs and metrics from one service type. +Example: If logs or metrics are collected from Elasticsearch, `service.type` would be `elasticsearch`. type: keyword -example: 1100110011 +example: elasticsearch -- -*`rule.version`*:: +*`service.version`*:: + -- -The version / revision of the rule being used for analysis. +Version of the service the data was collected from. +This allows to look at a data set only for a specific version of a service. type: keyword -example: 1.1 +example: 3.2.4 -- [float] -=== server +=== source -A Server is defined as the responder in a network connection for events regarding sessions, connections, or bidirectional flow records. -For TCP events, the server is the receiver of the initial SYN packet(s) of the TCP connection. For other protocols, the server is generally the responder in the network transaction. Some systems actually use the term "responder" to refer the server in TCP connections. The server fields describe details about the system acting as the server in the network event. Server fields are usually populated in conjunction with client fields. Server fields are generally not populated for packet-level events. -Client / server representations can add semantic context to an exchange, which is helpful to visualize the data in certain situations. If your context falls in that category, you should still ensure that source and destination are filled appropriately. +Source fields describe details about the source of a packet/event. +Source fields are usually populated in conjunction with destination fields. -*`server.address`*:: +*`source.address`*:: + -- -Some event server addresses are defined ambiguously. The event will sometimes list an IP, a domain or a unix socket. You should always store the raw address in the `.address` field. +Some event source addresses are defined ambiguously. The event will sometimes list an IP, a domain or a unix socket. You should always store the raw address in the `.address` field. Then it should be duplicated to `.ip` or `.domain`, depending on which one it is. type: keyword -- -*`server.as.number`*:: +*`source.as.number`*:: + -- Unique number allocated to the autonomous system. The autonomous system number (ASN) uniquely identifies each network on the Internet. @@ -10110,7 +11277,7 @@ example: 15169 -- -*`server.as.organization.name`*:: +*`source.as.organization.name`*:: + -- Organization name. @@ -10121,17 +11288,17 @@ example: Google LLC -- -*`server.as.organization.name.text`*:: +*`source.as.organization.name.text`*:: + -- type: text -- -*`server.bytes`*:: +*`source.bytes`*:: + -- -Bytes sent from the server to the client. +Bytes sent from the source to the destination. type: long @@ -10141,16 +11308,16 @@ format: bytes -- -*`server.domain`*:: +*`source.domain`*:: + -- -Server domain. +Source domain. type: keyword -- -*`server.geo.city_name`*:: +*`source.geo.city_name`*:: + -- City name. @@ -10161,7 +11328,7 @@ example: Montreal -- -*`server.geo.continent_name`*:: +*`source.geo.continent_name`*:: + -- Name of the continent. @@ -10172,7 +11339,7 @@ example: North America -- -*`server.geo.country_iso_code`*:: +*`source.geo.country_iso_code`*:: + -- Country ISO code. @@ -10183,7 +11350,7 @@ example: CA -- -*`server.geo.country_name`*:: +*`source.geo.country_name`*:: + -- Country name. @@ -10194,7 +11361,7 @@ example: Canada -- -*`server.geo.location`*:: +*`source.geo.location`*:: + -- Longitude and latitude. @@ -10205,7 +11372,7 @@ example: { "lon": -73.614830, "lat": 45.505918 } -- -*`server.geo.name`*:: +*`source.geo.name`*:: + -- User-defined description of a location, at the level of granularity they care about. @@ -10218,7 +11385,7 @@ example: boston-dc -- -*`server.geo.region_iso_code`*:: +*`source.geo.region_iso_code`*:: + -- Region ISO code. @@ -10229,7 +11396,7 @@ example: CA-QC -- -*`server.geo.region_name`*:: +*`source.geo.region_name`*:: + -- Region name. @@ -10240,39 +11407,39 @@ example: Quebec -- -*`server.ip`*:: +*`source.ip`*:: + -- -IP address of the server. +IP address of the source. Can be one or multiple IPv4 or IPv6 addresses. type: ip -- -*`server.mac`*:: +*`source.mac`*:: + -- -MAC address of the server. +MAC address of the source. type: keyword -- -*`server.nat.ip`*:: +*`source.nat.ip`*:: + -- -Translated ip of destination based NAT sessions (e.g. internet to private DMZ) -Typically used with load balancers, firewalls, or routers. +Translated ip of source based NAT sessions (e.g. internal client to internet) +Typically connections traversing load balancers, firewalls, or routers. type: ip -- -*`server.nat.port`*:: +*`source.nat.port`*:: + -- -Translated port of destination based NAT sessions (e.g. internet to private DMZ) +Translated port of source based NAT sessions. (e.g. internal client to internet) Typically used with load balancers, firewalls, or routers. type: long @@ -10281,10 +11448,10 @@ format: string -- -*`server.packets`*:: +*`source.packets`*:: + -- -Packets sent from the server to the client. +Packets sent from the source to the destination. type: long @@ -10292,10 +11459,10 @@ example: 12 -- -*`server.port`*:: +*`source.port`*:: + -- -Port of the server. +Port of the source. type: long @@ -10303,10 +11470,10 @@ format: string -- -*`server.registered_domain`*:: +*`source.registered_domain`*:: + -- -The highest registered server domain, stripped of the subdomain. +The highest registered source domain, stripped of the subdomain. For example, the registered domain for "foo.google.com" is "google.com". This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last two labels will not work well for TLDs such as "co.uk". @@ -10316,7 +11483,7 @@ example: google.com -- -*`server.top_level_domain`*:: +*`source.top_level_domain`*:: + -- The effective top level domain (eTLD), also known as the domain suffix, is the last part of the domain name. For example, the top level domain for google.com is "com". @@ -10328,7 +11495,7 @@ example: co.uk -- -*`server.user.domain`*:: +*`source.user.domain`*:: + -- Name of the directory the user is a member of. @@ -10338,7 +11505,7 @@ type: keyword -- -*`server.user.email`*:: +*`source.user.email`*:: + -- User email address. @@ -10347,7 +11514,7 @@ type: keyword -- -*`server.user.full_name`*:: +*`source.user.full_name`*:: + -- User's full name, if available. @@ -10358,14 +11525,14 @@ example: Albert Einstein -- -*`server.user.full_name.text`*:: +*`source.user.full_name.text`*:: + -- type: text -- -*`server.user.group.domain`*:: +*`source.user.group.domain`*:: + -- Name of the directory the group is a member of. @@ -10375,1759 +11542,1710 @@ type: keyword -- -*`server.user.group.id`*:: -+ --- -Unique identifier for the group on the system/platform. - -type: keyword - --- - -*`server.user.group.name`*:: -+ --- -Name of the group. - -type: keyword - --- - -*`server.user.hash`*:: -+ --- -Unique user hash to correlate information for a user in anonymized form. -Useful if `user.id` or `user.name` contain confidential information and cannot be used. - -type: keyword - --- - -*`server.user.id`*:: -+ --- -One or multiple unique identifiers of the user. - -type: keyword - --- - -*`server.user.name`*:: -+ --- -Short name or login of the user. - -type: keyword - -example: albert - --- - -*`server.user.name.text`*:: -+ --- -type: text - --- - -[float] -=== service - -The service fields describe the service for or from which the data was collected. -These fields help you find and correlate logs for a specific service and version. - - -*`service.ephemeral_id`*:: -+ --- -Ephemeral identifier of this service (if one exists). -This id normally changes across restarts, but `service.id` does not. - -type: keyword - -example: 8a4f500f - --- - -*`service.id`*:: -+ --- -Unique identifier of the running service. If the service is comprised of many nodes, the `service.id` should be the same for all nodes. -This id should uniquely identify the service. This makes it possible to correlate logs and metrics for one specific service, no matter which particular node emitted the event. -Note that if you need to see the events from one specific host of the service, you should filter on that `host.name` or `host.id` instead. - -type: keyword - -example: d37e5ebfe0ae6c4972dbe9f0174a1637bb8247f6 - --- - -*`service.name`*:: +*`source.user.group.id`*:: + -- -Name of the service data is collected from. -The name of the service is normally user given. This allows for distributed services that run on multiple hosts to correlate the related instances based on the name. -In the case of Elasticsearch the `service.name` could contain the cluster name. For Beats the `service.name` is by default a copy of the `service.type` field if no name is specified. +Unique identifier for the group on the system/platform. type: keyword -example: elasticsearch-metrics - -- -*`service.node.name`*:: +*`source.user.group.name`*:: + -- -Name of a service node. -This allows for two nodes of the same service running on the same host to be differentiated. Therefore, `service.node.name` should typically be unique across nodes of a given service. -In the case of Elasticsearch, the `service.node.name` could contain the unique node name within the Elasticsearch cluster. In cases where the service doesn't have the concept of a node name, the host name or container name can be used to distinguish running instances that make up this service. If those do not provide uniqueness (e.g. multiple instances of the service running on the same host) - the node name can be manually set. +Name of the group. type: keyword -example: instance-0000000016 - -- -*`service.state`*:: +*`source.user.hash`*:: + -- -Current state of the service. +Unique user hash to correlate information for a user in anonymized form. +Useful if `user.id` or `user.name` contain confidential information and cannot be used. type: keyword -- -*`service.type`*:: +*`source.user.id`*:: + -- -The type of the service data is collected from. -The type can be used to group and correlate logs and metrics from one service type. -Example: If logs or metrics are collected from Elasticsearch, `service.type` would be `elasticsearch`. +One or multiple unique identifiers of the user. type: keyword -example: elasticsearch - -- -*`service.version`*:: +*`source.user.name`*:: + -- -Version of the service the data was collected from. -This allows to look at a data set only for a specific version of a service. +Short name or login of the user. type: keyword -example: 3.2.4 +example: albert + +-- + +*`source.user.name.text`*:: ++ +-- +type: text -- [float] -=== source +=== threat -Source fields describe details about the source of a packet/event. -Source fields are usually populated in conjunction with destination fields. +Fields to classify events and alerts according to a threat taxonomy such as the Mitre ATT&CK framework. +These fields are for users to classify alerts from all of their sources (e.g. IDS, NGFW, etc.) within a common taxonomy. The threat.tactic.* are meant to capture the high level category of the threat (e.g. "impact"). The threat.technique.* fields are meant to capture which kind of approach is used by this detected threat, to accomplish the goal (e.g. "endpoint denial of service"). -*`source.address`*:: +*`threat.framework`*:: + -- -Some event source addresses are defined ambiguously. The event will sometimes list an IP, a domain or a unix socket. You should always store the raw address in the `.address` field. -Then it should be duplicated to `.ip` or `.domain`, depending on which one it is. +Name of the threat framework used to further categorize and classify the tactic and technique of the reported threat. Framework classification can be provided by detecting systems, evaluated at ingest time, or retrospectively tagged to events. type: keyword +example: MITRE ATT&CK + -- -*`source.as.number`*:: +*`threat.tactic.id`*:: + -- -Unique number allocated to the autonomous system. The autonomous system number (ASN) uniquely identifies each network on the Internet. +The id of tactic used by this threat. You can use the Mitre ATT&CK Matrix Tactic categorization, for example. (ex. https://attack.mitre.org/tactics/TA0040/ ) -type: long +type: keyword -example: 15169 +example: TA0040 -- -*`source.as.organization.name`*:: +*`threat.tactic.name`*:: + -- -Organization name. +Name of the type of tactic used by this threat. You can use the Mitre ATT&CK Matrix Tactic categorization, for example. (ex. https://attack.mitre.org/tactics/TA0040/ ) type: keyword -example: Google LLC - --- - -*`source.as.organization.name.text`*:: -+ --- -type: text +example: impact -- -*`source.bytes`*:: +*`threat.tactic.reference`*:: + -- -Bytes sent from the source to the destination. - -type: long +The reference url of tactic used by this threat. You can use the Mitre ATT&CK Matrix Tactic categorization, for example. (ex. https://attack.mitre.org/tactics/TA0040/ ) -example: 184 +type: keyword -format: bytes +example: https://attack.mitre.org/tactics/TA0040/ -- -*`source.domain`*:: +*`threat.technique.id`*:: + -- -Source domain. +The id of technique used by this tactic. You can use the Mitre ATT&CK Matrix Tactic categorization, for example. (ex. https://attack.mitre.org/techniques/T1499/ ) type: keyword +example: T1499 + -- -*`source.geo.city_name`*:: +*`threat.technique.name`*:: + -- -City name. +The name of technique used by this tactic. You can use the Mitre ATT&CK Matrix Tactic categorization, for example. (ex. https://attack.mitre.org/techniques/T1499/ ) type: keyword -example: Montreal +example: endpoint denial of service -- -*`source.geo.continent_name`*:: +*`threat.technique.name.text`*:: + -- -Name of the continent. - -type: keyword - -example: North America +type: text -- -*`source.geo.country_iso_code`*:: +*`threat.technique.reference`*:: + -- -Country ISO code. +The reference url of technique used by this tactic. You can use the Mitre ATT&CK Matrix Tactic categorization, for example. (ex. https://attack.mitre.org/techniques/T1499/ ) type: keyword -example: CA +example: https://attack.mitre.org/techniques/T1499/ -- -*`source.geo.country_name`*:: +[float] +=== tls + +Fields related to a TLS connection. These fields focus on the TLS protocol itself and intentionally avoids in-depth analysis of the related x.509 certificate files. + + +*`tls.cipher`*:: + -- -Country name. +String indicating the cipher used during the current connection. type: keyword -example: Canada +example: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 -- -*`source.geo.location`*:: +*`tls.client.certificate`*:: + -- -Longitude and latitude. +PEM-encoded stand-alone certificate offered by the client. This is usually mutually-exclusive of `client.certificate_chain` since this value also exists in that list. -type: geo_point +type: keyword -example: { "lon": -73.614830, "lat": 45.505918 } +example: MII... -- -*`source.geo.name`*:: +*`tls.client.certificate_chain`*:: + -- -User-defined description of a location, at the level of granularity they care about. -Could be the name of their data centers, the floor number, if this describes a local physical entity, city names. -Not typically used in automated geolocation. +Array of PEM-encoded certificates that make up the certificate chain offered by the client. This is usually mutually-exclusive of `client.certificate` since that value should be the first certificate in the chain. type: keyword -example: boston-dc +example: ['MII...', 'MII...'] -- -*`source.geo.region_iso_code`*:: +*`tls.client.hash.md5`*:: + -- -Region ISO code. +Certificate fingerprint using the MD5 digest of DER-encoded version of certificate offered by the client. For consistency with other hash values, this value should be formatted as an uppercase hash. type: keyword -example: CA-QC +example: 0F76C7F2C55BFD7D8E8B8F4BFBF0C9EC -- -*`source.geo.region_name`*:: +*`tls.client.hash.sha1`*:: + -- -Region name. +Certificate fingerprint using the SHA1 digest of DER-encoded version of certificate offered by the client. For consistency with other hash values, this value should be formatted as an uppercase hash. type: keyword -example: Quebec +example: 9E393D93138888D288266C2D915214D1D1CCEB2A -- -*`source.ip`*:: +*`tls.client.hash.sha256`*:: + -- -IP address of the source. -Can be one or multiple IPv4 or IPv6 addresses. +Certificate fingerprint using the SHA256 digest of DER-encoded version of certificate offered by the client. For consistency with other hash values, this value should be formatted as an uppercase hash. -type: ip +type: keyword + +example: 0687F666A054EF17A08E2F2162EAB4CBC0D265E1D7875BE74BF3C712CA92DAF0 -- -*`source.mac`*:: +*`tls.client.issuer`*:: + -- -MAC address of the source. +Distinguished name of subject of the issuer of the x.509 certificate presented by the client. type: keyword +example: CN=MyDomain Root CA, OU=Infrastructure Team, DC=mydomain, DC=com + -- -*`source.nat.ip`*:: +*`tls.client.ja3`*:: + -- -Translated ip of source based NAT sessions (e.g. internal client to internet) -Typically connections traversing load balancers, firewalls, or routers. +A hash that identifies clients based on how they perform an SSL/TLS handshake. -type: ip +type: keyword + +example: d4e5b18d6b55c71272893221c96ba240 -- -*`source.nat.port`*:: +*`tls.client.not_after`*:: + -- -Translated port of source based NAT sessions. (e.g. internal client to internet) -Typically used with load balancers, firewalls, or routers. +Date/Time indicating when client certificate is no longer considered valid. -type: long +type: date -format: string +example: 2021-01-01T00:00:00.000Z -- -*`source.packets`*:: +*`tls.client.not_before`*:: + -- -Packets sent from the source to the destination. +Date/Time indicating when client certificate is first considered valid. -type: long +type: date -example: 12 +example: 1970-01-01T00:00:00.000Z -- -*`source.port`*:: +*`tls.client.server_name`*:: + -- -Port of the source. +Also called an SNI, this tells the server which hostname to which the client is attempting to connect. When this value is available, it should get copied to `destination.domain`. -type: long +type: keyword -format: string +example: www.elastic.co -- -*`source.registered_domain`*:: +*`tls.client.subject`*:: + -- -The highest registered source domain, stripped of the subdomain. -For example, the registered domain for "foo.google.com" is "google.com". -This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last two labels will not work well for TLDs such as "co.uk". +Distinguished name of subject of the x.509 certificate presented by the client. type: keyword -example: google.com +example: CN=myclient, OU=Documentation Team, DC=mydomain, DC=com -- -*`source.top_level_domain`*:: +*`tls.client.supported_ciphers`*:: + -- -The effective top level domain (eTLD), also known as the domain suffix, is the last part of the domain name. For example, the top level domain for google.com is "com". -This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last label will not work well for effective TLDs such as "co.uk". +Array of ciphers offered by the client during the client hello. type: keyword -example: co.uk +example: ['TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384', 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384', '...'] -- -*`source.user.domain`*:: +*`tls.curve`*:: + -- -Name of the directory the user is a member of. -For example, an LDAP or Active Directory domain name. +String indicating the curve used for the given cipher, when applicable. type: keyword +example: secp256r1 + -- -*`source.user.email`*:: +*`tls.established`*:: + -- -User email address. +Boolean flag indicating if the TLS negotiation was successful and transitioned to an encrypted tunnel. -type: keyword +type: boolean -- -*`source.user.full_name`*:: +*`tls.next_protocol`*:: + -- -User's full name, if available. +String indicating the protocol being tunneled. Per the values in the IANA registry (https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids), this string should be lower case. type: keyword -example: Albert Einstein - --- - -*`source.user.full_name.text`*:: -+ --- -type: text +example: http/1.1 -- -*`source.user.group.domain`*:: +*`tls.resumed`*:: + -- -Name of the directory the group is a member of. -For example, an LDAP or Active Directory domain name. +Boolean flag indicating if this TLS connection was resumed from an existing TLS negotiation. -type: keyword +type: boolean -- -*`source.user.group.id`*:: +*`tls.server.certificate`*:: + -- -Unique identifier for the group on the system/platform. +PEM-encoded stand-alone certificate offered by the server. This is usually mutually-exclusive of `server.certificate_chain` since this value also exists in that list. type: keyword +example: MII... + -- -*`source.user.group.name`*:: +*`tls.server.certificate_chain`*:: + -- -Name of the group. +Array of PEM-encoded certificates that make up the certificate chain offered by the server. This is usually mutually-exclusive of `server.certificate` since that value should be the first certificate in the chain. type: keyword +example: ['MII...', 'MII...'] + -- -*`source.user.hash`*:: +*`tls.server.hash.md5`*:: + -- -Unique user hash to correlate information for a user in anonymized form. -Useful if `user.id` or `user.name` contain confidential information and cannot be used. +Certificate fingerprint using the MD5 digest of DER-encoded version of certificate offered by the server. For consistency with other hash values, this value should be formatted as an uppercase hash. type: keyword +example: 0F76C7F2C55BFD7D8E8B8F4BFBF0C9EC + -- -*`source.user.id`*:: +*`tls.server.hash.sha1`*:: + -- -One or multiple unique identifiers of the user. +Certificate fingerprint using the SHA1 digest of DER-encoded version of certificate offered by the server. For consistency with other hash values, this value should be formatted as an uppercase hash. type: keyword +example: 9E393D93138888D288266C2D915214D1D1CCEB2A + -- -*`source.user.name`*:: +*`tls.server.hash.sha256`*:: + -- -Short name or login of the user. +Certificate fingerprint using the SHA256 digest of DER-encoded version of certificate offered by the server. For consistency with other hash values, this value should be formatted as an uppercase hash. type: keyword -example: albert +example: 0687F666A054EF17A08E2F2162EAB4CBC0D265E1D7875BE74BF3C712CA92DAF0 -- -*`source.user.name.text`*:: +*`tls.server.issuer`*:: + -- -type: text - --- +Subject of the issuer of the x.509 certificate presented by the server. -[float] -=== threat +type: keyword -Fields to classify events and alerts according to a threat taxonomy such as the Mitre ATT&CK framework. -These fields are for users to classify alerts from all of their sources (e.g. IDS, NGFW, etc.) within a common taxonomy. The threat.tactic.* are meant to capture the high level category of the threat (e.g. "impact"). The threat.technique.* fields are meant to capture which kind of approach is used by this detected threat, to accomplish the goal (e.g. "endpoint denial of service"). +example: CN=MyDomain Root CA, OU=Infrastructure Team, DC=mydomain, DC=com +-- -*`threat.framework`*:: +*`tls.server.ja3s`*:: + -- -Name of the threat framework used to further categorize and classify the tactic and technique of the reported threat. Framework classification can be provided by detecting systems, evaluated at ingest time, or retrospectively tagged to events. +A hash that identifies servers based on how they perform an SSL/TLS handshake. type: keyword -example: MITRE ATT&CK +example: 394441ab65754e2207b1e1b457b3641d -- -*`threat.tactic.id`*:: +*`tls.server.not_after`*:: + -- -The id of tactic used by this threat. You can use the Mitre ATT&CK Matrix Tactic categorization, for example. (ex. https://attack.mitre.org/tactics/TA0040/ ) +Timestamp indicating when server certificate is no longer considered valid. -type: keyword +type: date -example: TA0040 +example: 2021-01-01T00:00:00.000Z -- -*`threat.tactic.name`*:: +*`tls.server.not_before`*:: + -- -Name of the type of tactic used by this threat. You can use the Mitre ATT&CK Matrix Tactic categorization, for example. (ex. https://attack.mitre.org/tactics/TA0040/ ) +Timestamp indicating when server certificate is first considered valid. -type: keyword +type: date -example: impact +example: 1970-01-01T00:00:00.000Z -- -*`threat.tactic.reference`*:: +*`tls.server.subject`*:: + -- -The reference url of tactic used by this threat. You can use the Mitre ATT&CK Matrix Tactic categorization, for example. (ex. https://attack.mitre.org/tactics/TA0040/ ) +Subject of the x.509 certificate presented by the server. type: keyword -example: https://attack.mitre.org/tactics/TA0040/ +example: CN=www.mydomain.com, OU=Infrastructure Team, DC=mydomain, DC=com -- -*`threat.technique.id`*:: +*`tls.version`*:: + -- -The id of technique used by this tactic. You can use the Mitre ATT&CK Matrix Tactic categorization, for example. (ex. https://attack.mitre.org/techniques/T1499/ ) +Numeric part of the version parsed from the original string. type: keyword -example: T1499 +example: 1.2 -- -*`threat.technique.name`*:: +*`tls.version_protocol`*:: + -- -The name of technique used by this tactic. You can use the Mitre ATT&CK Matrix Tactic categorization, for example. (ex. https://attack.mitre.org/techniques/T1499/ ) +Normalized lowercase protocol name parsed from original string. type: keyword -example: endpoint denial of service +example: tls -- -*`threat.technique.name.text`*:: +[float] +=== tracing + +Distributed tracing makes it possible to analyze performance throughout a microservice architecture all in one view. This is accomplished by tracing all of the requests - from the initial web request in the front-end service - to queries made through multiple back-end services. + + +*`tracing.trace.id`*:: + -- -type: text +Unique identifier of the trace. +A trace groups multiple events like transactions that belong together. For example, a user request handled by multiple inter-connected services. + +type: keyword + +example: 4bf92f3577b34da6a3ce929d0e0e4736 -- -*`threat.technique.reference`*:: +*`tracing.transaction.id`*:: + -- -The reference url of technique used by this tactic. You can use the Mitre ATT&CK Matrix Tactic categorization, for example. (ex. https://attack.mitre.org/techniques/T1499/ ) +Unique identifier of the transaction. +A transaction is the highest level of work measured within a service, such as a request to a server. type: keyword -example: https://attack.mitre.org/techniques/T1499/ +example: 00f067aa0ba902b7 -- [float] -=== tls +=== url -Fields related to a TLS connection. These fields focus on the TLS protocol itself and intentionally avoids in-depth analysis of the related x.509 certificate files. +URL fields provide support for complete or partial URLs, and supports the breaking down into scheme, domain, path, and so on. -*`tls.cipher`*:: +*`url.domain`*:: + -- -String indicating the cipher used during the current connection. +Domain of the url, such as "www.elastic.co". +In some cases a URL may refer to an IP and/or port directly, without a domain name. In this case, the IP address would go to the `domain` field. type: keyword -example: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 +example: www.elastic.co -- -*`tls.client.certificate`*:: +*`url.extension`*:: + -- -PEM-encoded stand-alone certificate offered by the client. This is usually mutually-exclusive of `client.certificate_chain` since this value also exists in that list. +The field contains the file extension from the original request url. +The file extension is only set if it exists, as not every url has a file extension. +The leading period must not be included. For example, the value must be "png", not ".png". type: keyword -example: MII... +example: png -- -*`tls.client.certificate_chain`*:: +*`url.fragment`*:: + -- -Array of PEM-encoded certificates that make up the certificate chain offered by the client. This is usually mutually-exclusive of `client.certificate` since that value should be the first certificate in the chain. +Portion of the url after the `#`, such as "top". +The `#` is not part of the fragment. type: keyword -example: ['MII...', 'MII...'] - -- -*`tls.client.hash.md5`*:: +*`url.full`*:: + -- -Certificate fingerprint using the MD5 digest of DER-encoded version of certificate offered by the client. For consistency with other hash values, this value should be formatted as an uppercase hash. +If full URLs are important to your use case, they should be stored in `url.full`, whether this field is reconstructed or present in the event source. type: keyword -example: 0F76C7F2C55BFD7D8E8B8F4BFBF0C9EC +example: https://www.elastic.co:443/search?q=elasticsearch#top -- -*`tls.client.hash.sha1`*:: +*`url.full.text`*:: + -- -Certificate fingerprint using the SHA1 digest of DER-encoded version of certificate offered by the client. For consistency with other hash values, this value should be formatted as an uppercase hash. - -type: keyword - -example: 9E393D93138888D288266C2D915214D1D1CCEB2A +type: text -- -*`tls.client.hash.sha256`*:: +*`url.original`*:: + -- -Certificate fingerprint using the SHA256 digest of DER-encoded version of certificate offered by the client. For consistency with other hash values, this value should be formatted as an uppercase hash. +Unmodified original url as seen in the event source. +Note that in network monitoring, the observed URL may be a full URL, whereas in access logs, the URL is often just represented as a path. +This field is meant to represent the URL as it was observed, complete or not. type: keyword -example: 0687F666A054EF17A08E2F2162EAB4CBC0D265E1D7875BE74BF3C712CA92DAF0 +example: https://www.elastic.co:443/search?q=elasticsearch#top or /search?q=elasticsearch -- -*`tls.client.issuer`*:: +*`url.original.text`*:: + -- -Distinguished name of subject of the issuer of the x.509 certificate presented by the client. +type: text -type: keyword +-- -example: CN=MyDomain Root CA, OU=Infrastructure Team, DC=mydomain, DC=com +*`url.password`*:: ++ +-- +Password of the request. + +type: keyword -- -*`tls.client.ja3`*:: +*`url.path`*:: + -- -A hash that identifies clients based on how they perform an SSL/TLS handshake. +Path of the request, such as "/search". type: keyword -example: d4e5b18d6b55c71272893221c96ba240 - -- -*`tls.client.not_after`*:: +*`url.port`*:: + -- -Date/Time indicating when client certificate is no longer considered valid. +Port of the request, such as 443. -type: date +type: long -example: 2021-01-01T00:00:00.000Z +example: 443 + +format: string -- -*`tls.client.not_before`*:: +*`url.query`*:: + -- -Date/Time indicating when client certificate is first considered valid. - -type: date +The query field describes the query string of the request, such as "q=elasticsearch". +The `?` is excluded from the query string. If a URL contains no `?`, there is no query field. If there is a `?` but no query, the query field exists with an empty string. The `exists` query can be used to differentiate between the two cases. -example: 1970-01-01T00:00:00.000Z +type: keyword -- -*`tls.client.server_name`*:: +*`url.registered_domain`*:: + -- -Also called an SNI, this tells the server which hostname to which the client is attempting to connect. When this value is available, it should get copied to `destination.domain`. +The highest registered url domain, stripped of the subdomain. +For example, the registered domain for "foo.google.com" is "google.com". +This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last two labels will not work well for TLDs such as "co.uk". type: keyword -example: www.elastic.co +example: google.com -- -*`tls.client.subject`*:: +*`url.scheme`*:: + -- -Distinguished name of subject of the x.509 certificate presented by the client. +Scheme of the request, such as "https". +Note: The `:` is not part of the scheme. type: keyword -example: CN=myclient, OU=Documentation Team, DC=mydomain, DC=com +example: https -- -*`tls.client.supported_ciphers`*:: +*`url.top_level_domain`*:: + -- -Array of ciphers offered by the client during the client hello. +The effective top level domain (eTLD), also known as the domain suffix, is the last part of the domain name. For example, the top level domain for google.com is "com". +This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last label will not work well for effective TLDs such as "co.uk". type: keyword -example: ['TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384', 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384', '...'] +example: co.uk -- -*`tls.curve`*:: +*`url.username`*:: + -- -String indicating the curve used for the given cipher, when applicable. +Username of the request. type: keyword -example: secp256r1 +-- + +[float] +=== user + +The user fields describe information about the user that is relevant to the event. +Fields can have one entry or multiple entries. If a user has more than one id, provide an array that includes all of them. + + +*`user.domain`*:: ++ +-- +Name of the directory the user is a member of. +For example, an LDAP or Active Directory domain name. + +type: keyword -- -*`tls.established`*:: +*`user.email`*:: + -- -Boolean flag indicating if the TLS negotiation was successful and transitioned to an encrypted tunnel. +User email address. -type: boolean +type: keyword -- -*`tls.next_protocol`*:: +*`user.full_name`*:: + -- -String indicating the protocol being tunneled. Per the values in the IANA registry (https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids), this string should be lower case. +User's full name, if available. type: keyword -example: http/1.1 +example: Albert Einstein -- -*`tls.resumed`*:: +*`user.full_name.text`*:: + -- -Boolean flag indicating if this TLS connection was resumed from an existing TLS negotiation. +type: text -type: boolean +-- + +*`user.group.domain`*:: ++ +-- +Name of the directory the group is a member of. +For example, an LDAP or Active Directory domain name. + +type: keyword -- -*`tls.server.certificate`*:: +*`user.group.id`*:: + -- -PEM-encoded stand-alone certificate offered by the server. This is usually mutually-exclusive of `server.certificate_chain` since this value also exists in that list. +Unique identifier for the group on the system/platform. type: keyword -example: MII... - -- -*`tls.server.certificate_chain`*:: +*`user.group.name`*:: + -- -Array of PEM-encoded certificates that make up the certificate chain offered by the server. This is usually mutually-exclusive of `server.certificate` since that value should be the first certificate in the chain. +Name of the group. type: keyword -example: ['MII...', 'MII...'] - -- -*`tls.server.hash.md5`*:: +*`user.hash`*:: + -- -Certificate fingerprint using the MD5 digest of DER-encoded version of certificate offered by the server. For consistency with other hash values, this value should be formatted as an uppercase hash. +Unique user hash to correlate information for a user in anonymized form. +Useful if `user.id` or `user.name` contain confidential information and cannot be used. type: keyword -example: 0F76C7F2C55BFD7D8E8B8F4BFBF0C9EC - -- -*`tls.server.hash.sha1`*:: +*`user.id`*:: + -- -Certificate fingerprint using the SHA1 digest of DER-encoded version of certificate offered by the server. For consistency with other hash values, this value should be formatted as an uppercase hash. +One or multiple unique identifiers of the user. type: keyword -example: 9E393D93138888D288266C2D915214D1D1CCEB2A - -- -*`tls.server.hash.sha256`*:: +*`user.name`*:: + -- -Certificate fingerprint using the SHA256 digest of DER-encoded version of certificate offered by the server. For consistency with other hash values, this value should be formatted as an uppercase hash. +Short name or login of the user. type: keyword -example: 0687F666A054EF17A08E2F2162EAB4CBC0D265E1D7875BE74BF3C712CA92DAF0 +example: albert -- -*`tls.server.issuer`*:: +*`user.name.text`*:: + -- -Subject of the issuer of the x.509 certificate presented by the server. +type: text -type: keyword +-- -example: CN=MyDomain Root CA, OU=Infrastructure Team, DC=mydomain, DC=com +[float] +=== user_agent --- +The user_agent fields normally come from a browser request. +They often show up in web service logs coming from the parsed user agent string. -*`tls.server.ja3s`*:: + +*`user_agent.device.name`*:: + -- -A hash that identifies servers based on how they perform an SSL/TLS handshake. +Name of the device. type: keyword -example: 394441ab65754e2207b1e1b457b3641d +example: iPhone -- -*`tls.server.not_after`*:: +*`user_agent.name`*:: + -- -Timestamp indicating when server certificate is no longer considered valid. +Name of the user agent. -type: date +type: keyword -example: 2021-01-01T00:00:00.000Z +example: Safari -- -*`tls.server.not_before`*:: +*`user_agent.original`*:: + -- -Timestamp indicating when server certificate is first considered valid. +Unparsed user_agent string. -type: date +type: keyword -example: 1970-01-01T00:00:00.000Z +example: Mozilla/5.0 (iPhone; CPU iPhone OS 12_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1 -- -*`tls.server.subject`*:: +*`user_agent.original.text`*:: + -- -Subject of the x.509 certificate presented by the server. - -type: keyword - -example: CN=www.mydomain.com, OU=Infrastructure Team, DC=mydomain, DC=com +type: text -- -*`tls.version`*:: +*`user_agent.os.family`*:: + -- -Numeric part of the version parsed from the original string. +OS family (such as redhat, debian, freebsd, windows). type: keyword -example: 1.2 +example: debian -- -*`tls.version_protocol`*:: +*`user_agent.os.full`*:: + -- -Normalized lowercase protocol name parsed from original string. +Operating system name, including the version or code name. type: keyword -example: tls +example: Mac OS Mojave -- -[float] -=== tracing - -Distributed tracing makes it possible to analyze performance throughout a microservice architecture all in one view. This is accomplished by tracing all of the requests - from the initial web request in the front-end service - to queries made through multiple back-end services. +*`user_agent.os.full.text`*:: ++ +-- +type: text +-- -*`tracing.trace.id`*:: +*`user_agent.os.kernel`*:: + -- -Unique identifier of the trace. -A trace groups multiple events like transactions that belong together. For example, a user request handled by multiple inter-connected services. +Operating system kernel version as a raw string. type: keyword -example: 4bf92f3577b34da6a3ce929d0e0e4736 +example: 4.4.0-112-generic -- -*`tracing.transaction.id`*:: +*`user_agent.os.name`*:: + -- -Unique identifier of the transaction. -A transaction is the highest level of work measured within a service, such as a request to a server. +Operating system name, without the version. type: keyword -example: 00f067aa0ba902b7 +example: Mac OS X -- -[float] -=== url - -URL fields provide support for complete or partial URLs, and supports the breaking down into scheme, domain, path, and so on. +*`user_agent.os.name.text`*:: ++ +-- +type: text +-- -*`url.domain`*:: +*`user_agent.os.platform`*:: + -- -Domain of the url, such as "www.elastic.co". -In some cases a URL may refer to an IP and/or port directly, without a domain name. In this case, the IP address would go to the `domain` field. +Operating system platform (such centos, ubuntu, windows). type: keyword -example: www.elastic.co +example: darwin -- -*`url.extension`*:: +*`user_agent.os.version`*:: + -- -The field contains the file extension from the original request url. -The file extension is only set if it exists, as not every url has a file extension. -The leading period must not be included. For example, the value must be "png", not ".png". +Operating system version as a raw string. type: keyword -example: png +example: 10.14.1 -- -*`url.fragment`*:: +*`user_agent.version`*:: + -- -Portion of the url after the `#`, such as "top". -The `#` is not part of the fragment. +Version of the user agent. type: keyword +example: 12.0 + -- -*`url.full`*:: +[float] +=== vulnerability + +The vulnerability fields describe information about a vulnerability that is relevant to an event. + + +*`vulnerability.category`*:: + -- -If full URLs are important to your use case, they should be stored in `url.full`, whether this field is reconstructed or present in the event source. +The type of system or architecture that the vulnerability affects. These may be platform-specific (for example, Debian or SUSE) or general (for example, Database or Firewall). For example (https://qualysguard.qualys.com/qwebhelp/fo_portal/knowledgebase/vulnerability_categories.htm[Qualys vulnerability categories]) +This field must be an array. type: keyword -example: https://www.elastic.co:443/search?q=elasticsearch#top +example: ["Firewall"] -- -*`url.full.text`*:: +*`vulnerability.classification`*:: + -- -type: text +The classification of the vulnerability scoring system. For example (https://www.first.org/cvss/) + +type: keyword + +example: CVSS -- -*`url.original`*:: +*`vulnerability.description`*:: + -- -Unmodified original url as seen in the event source. -Note that in network monitoring, the observed URL may be a full URL, whereas in access logs, the URL is often just represented as a path. -This field is meant to represent the URL as it was observed, complete or not. +The description of the vulnerability that provides additional context of the vulnerability. For example (https://cve.mitre.org/about/faqs.html#cve_entry_descriptions_created[Common Vulnerabilities and Exposure CVE description]) type: keyword -example: https://www.elastic.co:443/search?q=elasticsearch#top or /search?q=elasticsearch +example: In macOS before 2.12.6, there is a vulnerability in the RPC... -- -*`url.original.text`*:: +*`vulnerability.description.text`*:: + -- type: text -- -*`url.password`*:: +*`vulnerability.enumeration`*:: + -- -Password of the request. +The type of identifier used for this vulnerability. For example (https://cve.mitre.org/about/) type: keyword --- - -*`url.path`*:: -+ --- -Path of the request, such as "/search". - -type: keyword +example: CVE -- -*`url.port`*:: +*`vulnerability.id`*:: + -- -Port of the request, such as 443. - -type: long +The identification (ID) is the number portion of a vulnerability entry. It includes a unique identification number for the vulnerability. For example (https://cve.mitre.org/about/faqs.html#what_is_cve_id)[Common Vulnerabilities and Exposure CVE ID] -example: 443 +type: keyword -format: string +example: CVE-2019-00001 -- -*`url.query`*:: +*`vulnerability.reference`*:: + -- -The query field describes the query string of the request, such as "q=elasticsearch". -The `?` is excluded from the query string. If a URL contains no `?`, there is no query field. If there is a `?` but no query, the query field exists with an empty string. The `exists` query can be used to differentiate between the two cases. +A resource that provides additional information, context, and mitigations for the identified vulnerability. type: keyword +example: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-6111 + -- -*`url.registered_domain`*:: +*`vulnerability.report_id`*:: + -- -The highest registered url domain, stripped of the subdomain. -For example, the registered domain for "foo.google.com" is "google.com". -This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last two labels will not work well for TLDs such as "co.uk". +The report or scan identification number. type: keyword -example: google.com +example: 20191018.0001 -- -*`url.scheme`*:: +*`vulnerability.scanner.vendor`*:: + -- -Scheme of the request, such as "https". -Note: The `:` is not part of the scheme. +The name of the vulnerability scanner vendor. type: keyword -example: https +example: Tenable -- -*`url.top_level_domain`*:: +*`vulnerability.score.base`*:: + -- -The effective top level domain (eTLD), also known as the domain suffix, is the last part of the domain name. For example, the top level domain for google.com is "com". -This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last label will not work well for effective TLDs such as "co.uk". +Scores can range from 0.0 to 10.0, with 10.0 being the most severe. +Base scores cover an assessment for exploitability metrics (attack vector, complexity, privileges, and user interaction), impact metrics (confidentiality, integrity, and availability), and scope. For example (https://www.first.org/cvss/specification-document) -type: keyword +type: float -example: co.uk +example: 5.5 -- -*`url.username`*:: +*`vulnerability.score.environmental`*:: + -- -Username of the request. - -type: keyword - --- +Scores can range from 0.0 to 10.0, with 10.0 being the most severe. +Environmental scores cover an assessment for any modified Base metrics, confidentiality, integrity, and availability requirements. For example (https://www.first.org/cvss/specification-document) -[float] -=== user +type: float -The user fields describe information about the user that is relevant to the event. -Fields can have one entry or multiple entries. If a user has more than one id, provide an array that includes all of them. +example: 5.5 +-- -*`user.domain`*:: +*`vulnerability.score.temporal`*:: + -- -Name of the directory the user is a member of. -For example, an LDAP or Active Directory domain name. +Scores can range from 0.0 to 10.0, with 10.0 being the most severe. +Temporal scores cover an assessment for code maturity, remediation level, and confidence. For example (https://www.first.org/cvss/specification-document) -type: keyword +type: float -- -*`user.email`*:: +*`vulnerability.score.version`*:: + -- -User email address. +The National Vulnerability Database (NVD) provides qualitative severity rankings of "Low", "Medium", and "High" for CVSS v2.0 base score ranges in addition to the severity ratings for CVSS v3.0 as they are defined in the CVSS v3.0 specification. +CVSS is owned and managed by FIRST.Org, Inc. (FIRST), a US-based non-profit organization, whose mission is to help computer security incident response teams across the world. For example (https://nvd.nist.gov/vuln-metrics/cvss) type: keyword +example: 2.0 + -- -*`user.full_name`*:: +*`vulnerability.severity`*:: + -- -User's full name, if available. +The severity of the vulnerability can help with metrics and internal prioritization regarding remediation. For example (https://nvd.nist.gov/vuln-metrics/cvss) type: keyword -example: Albert Einstein +example: Critical -- -*`user.full_name.text`*:: -+ --- -type: text +[[exported-fields-elasticsearch]] +== Elasticsearch fields --- +Elasticsearch module -*`user.group.domain`*:: -+ --- -Name of the directory the group is a member of. -For example, an LDAP or Active Directory domain name. -type: keyword --- +[float] +=== elasticsearch -*`user.group.id`*:: -+ --- -Unique identifier for the group on the system/platform. -type: keyword --- -*`user.group.name`*:: +*`elasticsearch.cluster.name`*:: + -- -Name of the group. +Elasticsearch cluster name. + type: keyword -- -*`user.hash`*:: +*`elasticsearch.cluster.id`*:: + -- -Unique user hash to correlate information for a user in anonymized form. -Useful if `user.id` or `user.name` contain confidential information and cannot be used. +Elasticsearch cluster id. + type: keyword -- -*`user.id`*:: +*`elasticsearch.cluster.state.id`*:: + -- -One or multiple unique identifiers of the user. +Elasticsearch state id. + type: keyword -- -*`user.name`*:: +*`elasticsearch.node.id`*:: + -- -Short name or login of the user. +Node ID -type: keyword -example: albert +type: keyword -- -*`user.name.text`*:: +*`elasticsearch.node.name`*:: + -- -type: text +Node name. + + +type: keyword -- [float] -=== user_agent +=== ccr -The user_agent fields normally come from a browser request. -They often show up in web service logs coming from the parsed user agent string. +Cross-cluster replication stats -*`user_agent.device.name`*:: + + +*`elasticsearch.ccr.leader.index`*:: + -- -Name of the device. +Name of leader index -type: keyword -example: iPhone +type: keyword -- -*`user_agent.name`*:: +*`elasticsearch.ccr.leader.max_seq_no`*:: + -- -Name of the user agent. +Maximum sequence number of operation on the leader shard -type: keyword -example: Safari +type: long -- -*`user_agent.original`*:: + +*`elasticsearch.ccr.follower.index`*:: + -- -Unparsed user_agent string. +Name of follower index -type: keyword -example: Mozilla/5.0 (iPhone; CPU iPhone OS 12_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1 +type: keyword -- -*`user_agent.original.text`*:: +*`elasticsearch.ccr.follower.shard.number`*:: + -- -type: text +Number of the shard within the index + + +type: long -- -*`user_agent.os.family`*:: +*`elasticsearch.ccr.follower.operations_written`*:: + -- -OS family (such as redhat, debian, freebsd, windows). +Number of operations indexed (replicated) into the follower shard from the leader shard -type: keyword -example: debian +type: long -- -*`user_agent.os.full`*:: +*`elasticsearch.ccr.follower.time_since_last_read.ms`*:: + -- -Operating system name, including the version or code name. +Time, in ms, since the follower last fetched from the leader -type: keyword -example: Mac OS Mojave +type: long -- -*`user_agent.os.full.text`*:: +*`elasticsearch.ccr.follower.global_checkpoint`*:: + -- -type: text +Global checkpoint value on follower shard --- -*`user_agent.os.kernel`*:: -+ +type: long + -- -Operating system kernel version as a raw string. -type: keyword +[float] +=== cluster.stats -example: 4.4.0-112-generic +Cluster stats --- -*`user_agent.os.name`*:: + +*`elasticsearch.cluster.stats.status`*:: + -- -Operating system name, without the version. +Cluster status (green, yellow, red). -type: keyword -example: Mac OS X +type: keyword -- -*`user_agent.os.name.text`*:: -+ --- -type: text +[float] +=== nodes --- +Nodes statistics. -*`user_agent.os.platform`*:: + + +*`elasticsearch.cluster.stats.nodes.count`*:: + -- -Operating system platform (such centos, ubuntu, windows). +Total number of nodes in cluster. -type: keyword -example: darwin +type: long -- -*`user_agent.os.version`*:: +*`elasticsearch.cluster.stats.nodes.master`*:: + -- -Operating system version as a raw string. +Number of master-eligible nodes in cluster. -type: keyword -example: 10.14.1 +type: long -- -*`user_agent.version`*:: +*`elasticsearch.cluster.stats.nodes.data`*:: + -- -Version of the user agent. +Number of data nodes in cluster. -type: keyword -example: 12.0 +type: long -- [float] -=== vulnerability +=== indices -The vulnerability fields describe information about a vulnerability that is relevant to an event. +Indices statistics. -*`vulnerability.category`*:: + +*`elasticsearch.cluster.stats.indices.count`*:: + -- -The type of system or architecture that the vulnerability affects. These may be platform-specific (for example, Debian or SUSE) or general (for example, Database or Firewall). For example (https://qualysguard.qualys.com/qwebhelp/fo_portal/knowledgebase/vulnerability_categories.htm[Qualys vulnerability categories]) -This field must be an array. +Total number of indices in cluster. -type: keyword -example: ["Firewall"] +type: long -- -*`vulnerability.classification`*:: +[float] +=== shards + +Shard statistics. + + + +*`elasticsearch.cluster.stats.indices.shards.count`*:: + -- -The classification of the vulnerability scoring system. For example (https://www.first.org/cvss/) +Total number of shards in cluster. -type: keyword -example: CVSS +type: long -- -*`vulnerability.description`*:: +*`elasticsearch.cluster.stats.indices.shards.primaries`*:: + -- -The description of the vulnerability that provides additional context of the vulnerability. For example (https://cve.mitre.org/about/faqs.html#cve_entry_descriptions_created[Common Vulnerabilities and Exposure CVE description]) +Total number of primary shards in cluster. -type: keyword -example: In macOS before 2.12.6, there is a vulnerability in the RPC... +type: long -- -*`vulnerability.description.text`*:: +*`elasticsearch.cluster.stats.indices.fielddata.memory.bytes`*:: + -- -type: text +Memory used for fielddata. + + +type: long -- -*`vulnerability.enumeration`*:: +[float] +=== enrich + +Enrich stats + + + +*`elasticsearch.enrich.queue.size`*:: + -- -The type of identifier used for this vulnerability. For example (https://cve.mitre.org/about/) +Number of search requests in the queue. -type: keyword -example: CVE +type: long -- -*`vulnerability.id`*:: + +*`elasticsearch.enrich.remote_requests.current`*:: + -- -The identification (ID) is the number portion of a vulnerability entry. It includes a unique identification number for the vulnerability. For example (https://cve.mitre.org/about/faqs.html#what_is_cve_id)[Common Vulnerabilities and Exposure CVE ID] +Current number of outstanding remote requests. -type: keyword -example: CVE-2019-00001 +type: long -- -*`vulnerability.reference`*:: +*`elasticsearch.enrich.remote_requests.total`*:: + -- -A resource that provides additional information, context, and mitigations for the identified vulnerability. +Number of outstanding remote requests executed since node startup. -type: keyword -example: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-6111 +type: long -- -*`vulnerability.report_id`*:: +*`elasticsearch.enrich.executed_searches.total`*:: + -- -The report or scan identification number. +Number of search requests that enrich processors have executed since node startup. -type: keyword -example: 20191018.0001 +type: long -- -*`vulnerability.scanner.vendor`*:: +[float] +=== index + +index + + + +*`elasticsearch.index.name`*:: + -- -The name of the vulnerability scanner vendor. +Index name. -type: keyword -example: Tenable +type: keyword -- -*`vulnerability.score.base`*:: + +*`elasticsearch.index.total.docs.count`*:: + -- -Scores can range from 0.0 to 10.0, with 10.0 being the most severe. -Base scores cover an assessment for exploitability metrics (attack vector, complexity, privileges, and user interaction), impact metrics (confidentiality, integrity, and availability), and scope. For example (https://www.first.org/cvss/specification-document) +Total number of documents in the index. -type: float -example: 5.5 +type: long -- -*`vulnerability.score.environmental`*:: +*`elasticsearch.index.total.docs.deleted`*:: + -- -Scores can range from 0.0 to 10.0, with 10.0 being the most severe. -Environmental scores cover an assessment for any modified Base metrics, confidentiality, integrity, and availability requirements. For example (https://www.first.org/cvss/specification-document) +Total number of deleted documents in the index. -type: float -example: 5.5 +type: long -- -*`vulnerability.score.temporal`*:: +*`elasticsearch.index.total.store.size.bytes`*:: + -- -Scores can range from 0.0 to 10.0, with 10.0 being the most severe. -Temporal scores cover an assessment for code maturity, remediation level, and confidence. For example (https://www.first.org/cvss/specification-document) +Total size of the index in bytes. -type: float + +type: long + +format: bytes -- -*`vulnerability.score.version`*:: +*`elasticsearch.index.total.segments.count`*:: + -- -The National Vulnerability Database (NVD) provides qualitative severity rankings of "Low", "Medium", and "High" for CVSS v2.0 base score ranges in addition to the severity ratings for CVSS v3.0 as they are defined in the CVSS v3.0 specification. -CVSS is owned and managed by FIRST.Org, Inc. (FIRST), a US-based non-profit organization, whose mission is to help computer security incident response teams across the world. For example (https://nvd.nist.gov/vuln-metrics/cvss) +Total number of index segments. -type: keyword -example: 2.0 +type: long -- -*`vulnerability.severity`*:: +*`elasticsearch.index.total.segments.memory.bytes`*:: + -- -The severity of the vulnerability can help with metrics and internal prioritization regarding remediation. For example (https://nvd.nist.gov/vuln-metrics/cvss) +Total number of memory used by the segments in bytes. -type: keyword -example: Critical +type: long + +format: bytes -- -[[exported-fields-elasticsearch]] -== Elasticsearch fields +[float] +=== index.recovery -Elasticsearch module +index -[float] -=== elasticsearch +*`elasticsearch.index.recovery.id`*:: ++ +-- +Shard recovery id. +type: long +-- -*`elasticsearch.cluster.name`*:: +*`elasticsearch.index.recovery.type`*:: + -- -Elasticsearch cluster name. +Shard recovery type. type: keyword -- -*`elasticsearch.cluster.id`*:: +*`elasticsearch.index.recovery.primary`*:: + -- -Elasticsearch cluster id. +True if primary shard. -type: keyword +type: boolean -- -*`elasticsearch.cluster.state.id`*:: +*`elasticsearch.index.recovery.stage`*:: + -- -Elasticsearch state id. +Recovery stage. type: keyword -- -*`elasticsearch.node.id`*:: +*`elasticsearch.index.recovery.target.id`*:: + -- -Node ID +Target node id. type: keyword -- -*`elasticsearch.node.name`*:: +*`elasticsearch.index.recovery.target.host`*:: + -- -Node name. +Target node host address (could be IP address or hostname). type: keyword -- -[float] -=== ccr - -Cross-cluster replication stats +*`elasticsearch.index.recovery.target.name`*:: ++ +-- +Target node name. +type: keyword +-- -*`elasticsearch.ccr.leader.index`*:: +*`elasticsearch.index.recovery.source.id`*:: + -- -Name of leader index +Source node id. type: keyword -- -*`elasticsearch.ccr.leader.max_seq_no`*:: +*`elasticsearch.index.recovery.source.host`*:: + -- -Maximum sequence number of operation on the leader shard +Source node host address (could be IP address or hostname). -type: long +type: keyword -- - -*`elasticsearch.ccr.follower.index`*:: +*`elasticsearch.index.recovery.source.name`*:: + -- -Name of follower index +Source node name. type: keyword -- -*`elasticsearch.ccr.follower.shard.number`*:: +[float] +=== index.summary + +index + + + + +*`elasticsearch.index.summary.primaries.docs.count`*:: + -- -Number of the shard within the index +Total number of documents in the index. type: long -- -*`elasticsearch.ccr.follower.operations_written`*:: +*`elasticsearch.index.summary.primaries.docs.deleted`*:: + -- -Number of operations indexed (replicated) into the follower shard from the leader shard +Total number of deleted documents in the index. type: long -- -*`elasticsearch.ccr.follower.time_since_last_read.ms`*:: +*`elasticsearch.index.summary.primaries.store.size.bytes`*:: + -- -Time, in ms, since the follower last fetched from the leader +Total size of the index in bytes. type: long +format: bytes + -- -*`elasticsearch.ccr.follower.global_checkpoint`*:: +*`elasticsearch.index.summary.primaries.segments.count`*:: + -- -Global checkpoint value on follower shard +Total number of index segments. type: long -- -[float] -=== cluster.stats +*`elasticsearch.index.summary.primaries.segments.memory.bytes`*:: ++ +-- +Total number of memory used by the segments in bytes. -Cluster stats +type: long + +format: bytes +-- -*`elasticsearch.cluster.stats.status`*:: + +*`elasticsearch.index.summary.total.docs.count`*:: + -- -Cluster status (green, yellow, red). +Total number of documents in the index. -type: keyword +type: long -- -[float] -=== nodes +*`elasticsearch.index.summary.total.docs.deleted`*:: ++ +-- +Total number of deleted documents in the index. -Nodes statistics. +type: long +-- -*`elasticsearch.cluster.stats.nodes.count`*:: +*`elasticsearch.index.summary.total.store.size.bytes`*:: + -- -Total number of nodes in cluster. +Total size of the index in bytes. type: long +format: bytes + -- -*`elasticsearch.cluster.stats.nodes.master`*:: +*`elasticsearch.index.summary.total.segments.count`*:: + -- -Number of master-eligible nodes in cluster. +Total number of index segments. type: long -- -*`elasticsearch.cluster.stats.nodes.data`*:: +*`elasticsearch.index.summary.total.segments.memory.bytes`*:: + -- -Number of data nodes in cluster. +Total number of memory used by the segments in bytes. type: long +format: bytes + -- [float] -=== indices +=== ml.job -Indices statistics. +ml -*`elasticsearch.cluster.stats.indices.count`*:: +*`elasticsearch.ml.job.id`*:: + -- -Total number of indices in cluster. +Unique ml job id. -type: long +type: keyword -- -[float] -=== shards - -Shard statistics. - - - -*`elasticsearch.cluster.stats.indices.shards.count`*:: +*`elasticsearch.ml.job.state`*:: + -- -Total number of shards in cluster. +Job state. -type: long +type: keyword -- -*`elasticsearch.cluster.stats.indices.shards.primaries`*:: +*`elasticsearch.ml.job.data_counts.processed_record_count`*:: + -- -Total number of primary shards in cluster. +Processed data events. type: long -- -*`elasticsearch.cluster.stats.indices.fielddata.memory.bytes`*:: +*`elasticsearch.ml.job.data_counts.invalid_date_count`*:: + -- -Memory used for fielddata. +The number of records with either a missing date field or a date that could not be parsed. type: long @@ -12135,95 +13253,79 @@ type: long -- [float] -=== enrich +=== node -Enrich stats +node -*`elasticsearch.enrich.queue.size`*:: +*`elasticsearch.node.version`*:: + -- -Number of search requests in the queue. +Node version. -type: long +type: keyword -- +[float] +=== jvm -*`elasticsearch.enrich.remote_requests.current`*:: -+ --- -Current number of outstanding remote requests. - +JVM Info. -type: long --- -*`elasticsearch.enrich.remote_requests.total`*:: +*`elasticsearch.node.jvm.version`*:: + -- -Number of outstanding remote requests executed since node startup. +JVM version. -type: long +type: keyword -- -*`elasticsearch.enrich.executed_searches.total`*:: +*`elasticsearch.node.jvm.memory.heap.init.bytes`*:: + -- -Number of search requests that enrich processors have executed since node startup. +Heap init used by the JVM in bytes. type: long --- - -[float] -=== index - -index - - - -*`elasticsearch.index.name`*:: -+ --- -Index name. - - -type: keyword +format: bytes -- - -*`elasticsearch.index.total.docs.count`*:: +*`elasticsearch.node.jvm.memory.heap.max.bytes`*:: + -- -Total number of documents in the index. +Heap max used by the JVM in bytes. type: long +format: bytes + -- -*`elasticsearch.index.total.docs.deleted`*:: +*`elasticsearch.node.jvm.memory.nonheap.init.bytes`*:: + -- -Total number of deleted documents in the index. +Non-Heap init used by the JVM in bytes. type: long +format: bytes + -- -*`elasticsearch.index.total.store.size.bytes`*:: +*`elasticsearch.node.jvm.memory.nonheap.max.bytes`*:: + -- -Total size of the index in bytes. +Non-Heap max used by the JVM in bytes. type: long @@ -12232,168 +13334,162 @@ format: bytes -- -*`elasticsearch.index.total.segments.count`*:: +*`elasticsearch.node.process.mlockall`*:: + -- -Total number of index segments. - +If process locked in memory. -type: long --- +type: boolean -*`elasticsearch.index.total.segments.memory.bytes`*:: -+ -- -Total number of memory used by the segments in bytes. +[float] +=== node.stats -type: long +node_stats -format: bytes --- [float] -=== index.recovery +=== indices -index +Node indices stats -*`elasticsearch.index.recovery.id`*:: +*`elasticsearch.node.stats.indices.docs.count`*:: + -- -Shard recovery id. +Total number of existing documents. type: long -- -*`elasticsearch.index.recovery.type`*:: +*`elasticsearch.node.stats.indices.docs.deleted`*:: + -- -Shard recovery type. +Total number of deleted documents. -type: keyword +type: long -- -*`elasticsearch.index.recovery.primary`*:: +*`elasticsearch.node.stats.indices.segments.count`*:: + -- -True if primary shard. +Total number of segments. -type: boolean +type: long -- -*`elasticsearch.index.recovery.stage`*:: +*`elasticsearch.node.stats.indices.segments.memory.bytes`*:: + -- -Recovery stage. +Total size of segments in bytes. -type: keyword +type: long + +format: bytes -- -*`elasticsearch.index.recovery.target.id`*:: +*`elasticsearch.node.stats.indices.store.size.bytes`*:: + -- -Target node id. +Total size of the store in bytes. -type: keyword +type: long -- -*`elasticsearch.index.recovery.target.host`*:: -+ --- -Target node host address (could be IP address or hostname). +[float] +=== jvm.mem.pools + +JVM memory pool stats -type: keyword --- +[float] +=== old -*`elasticsearch.index.recovery.target.name`*:: +Old memory pool stats. + + + +*`elasticsearch.node.stats.jvm.mem.pools.old.max.bytes`*:: + -- -Target node name. +Max bytes. +type: long -type: keyword +format: bytes -- -*`elasticsearch.index.recovery.source.id`*:: +*`elasticsearch.node.stats.jvm.mem.pools.old.peak.bytes`*:: + -- -Source node id. +Peak bytes. +type: long -type: keyword +format: bytes -- -*`elasticsearch.index.recovery.source.host`*:: +*`elasticsearch.node.stats.jvm.mem.pools.old.peak_max.bytes`*:: + -- -Source node host address (could be IP address or hostname). +Peak max bytes. +type: long -type: keyword +format: bytes -- -*`elasticsearch.index.recovery.source.name`*:: +*`elasticsearch.node.stats.jvm.mem.pools.old.used.bytes`*:: + -- -Source node name. +Used bytes. +type: long -type: keyword +format: bytes -- [float] -=== index.summary - -index +=== young +Young memory pool stats. -*`elasticsearch.index.summary.primaries.docs.count`*:: +*`elasticsearch.node.stats.jvm.mem.pools.young.max.bytes`*:: + -- -Total number of documents in the index. - +Max bytes. type: long --- - -*`elasticsearch.index.summary.primaries.docs.deleted`*:: -+ --- -Total number of deleted documents in the index. - - -type: long +format: bytes -- -*`elasticsearch.index.summary.primaries.store.size.bytes`*:: +*`elasticsearch.node.stats.jvm.mem.pools.young.peak.bytes`*:: + -- -Total size of the index in bytes. - +Peak bytes. type: long @@ -12401,21 +13497,21 @@ format: bytes -- -*`elasticsearch.index.summary.primaries.segments.count`*:: +*`elasticsearch.node.stats.jvm.mem.pools.young.peak_max.bytes`*:: + -- -Total number of index segments. - +Peak max bytes. type: long +format: bytes + -- -*`elasticsearch.index.summary.primaries.segments.memory.bytes`*:: +*`elasticsearch.node.stats.jvm.mem.pools.young.used.bytes`*:: + -- -Total number of memory used by the segments in bytes. - +Used bytes. type: long @@ -12423,32 +13519,28 @@ format: bytes -- +[float] +=== survivor -*`elasticsearch.index.summary.total.docs.count`*:: -+ --- -Total number of documents in the index. - +Survivor memory pool stats. -type: long --- -*`elasticsearch.index.summary.total.docs.deleted`*:: +*`elasticsearch.node.stats.jvm.mem.pools.survivor.max.bytes`*:: + -- -Total number of deleted documents in the index. - +Max bytes. type: long +format: bytes + -- -*`elasticsearch.index.summary.total.store.size.bytes`*:: +*`elasticsearch.node.stats.jvm.mem.pools.survivor.peak.bytes`*:: + -- -Total size of the index in bytes. - +Peak bytes. type: long @@ -12456,21 +13548,21 @@ format: bytes -- -*`elasticsearch.index.summary.total.segments.count`*:: +*`elasticsearch.node.stats.jvm.mem.pools.survivor.peak_max.bytes`*:: + -- -Total number of index segments. - +Peak max bytes. type: long +format: bytes + -- -*`elasticsearch.index.summary.total.segments.memory.bytes`*:: +*`elasticsearch.node.stats.jvm.mem.pools.survivor.used.bytes`*:: + -- -Total number of memory used by the segments in bytes. - +Used bytes. type: long @@ -12479,90 +13571,83 @@ format: bytes -- [float] -=== ml.job +=== jvm.gc.collectors -ml +GC collector stats. -*`elasticsearch.ml.job.id`*:: -+ --- -Unique ml job id. +[float] +=== old.collection +Old collection gc. -type: keyword --- -*`elasticsearch.ml.job.state`*:: +*`elasticsearch.node.stats.jvm.gc.collectors.old.collection.count`*:: + -- -Job state. -type: keyword +type: long -- -*`elasticsearch.ml.job.data_counts.processed_record_count`*:: +*`elasticsearch.node.stats.jvm.gc.collectors.old.collection.ms`*:: + -- -Processed data events. type: long -- -*`elasticsearch.ml.job.data_counts.invalid_date_count`*:: -+ --- -The number of records with either a missing date field or a date that could not be parsed. +[float] +=== young.collection + +Young collection gc. -type: long +*`elasticsearch.node.stats.jvm.gc.collectors.young.collection.count`*:: ++ -- -[float] -=== node - -node +type: long +-- -*`elasticsearch.node.version`*:: +*`elasticsearch.node.stats.jvm.gc.collectors.young.collection.ms`*:: + -- -Node version. -type: keyword +type: long -- [float] -=== jvm +=== fs.summary -JVM Info. +File system summary -*`elasticsearch.node.jvm.version`*:: +*`elasticsearch.node.stats.fs.summary.total.bytes`*:: + -- -JVM version. -type: keyword +type: long + +format: bytes -- -*`elasticsearch.node.jvm.memory.heap.init.bytes`*:: +*`elasticsearch.node.stats.fs.summary.free.bytes`*:: + -- -Heap init used by the JVM in bytes. type: long @@ -12571,10 +13656,9 @@ format: bytes -- -*`elasticsearch.node.jvm.memory.heap.max.bytes`*:: +*`elasticsearch.node.stats.fs.summary.available.bytes`*:: + -- -Heap max used by the JVM in bytes. type: long @@ -12583,1347 +13667,1339 @@ format: bytes -- -*`elasticsearch.node.jvm.memory.nonheap.init.bytes`*:: +[float] +=== cluster.pending_task + +`cluster.pending_task` contains a pending task description. + + + +*`elasticsearch.cluster.pending_task.insert_order`*:: + -- -Non-Heap init used by the JVM in bytes. +Insert order type: long -format: bytes - -- -*`elasticsearch.node.jvm.memory.nonheap.max.bytes`*:: +*`elasticsearch.cluster.pending_task.priority`*:: + -- -Non-Heap max used by the JVM in bytes. +Priority type: long -format: bytes - -- -*`elasticsearch.node.process.mlockall`*:: +*`elasticsearch.cluster.pending_task.source`*:: + -- -If process locked in memory. +Source. For example: put-mapping -type: boolean +type: keyword -- -[float] -=== node.stats +*`elasticsearch.cluster.pending_task.time_in_queue.ms`*:: ++ +-- +Time in queue -node_stats +type: long +-- [float] -=== indices +=== shard -Node indices stats +shard fields -*`elasticsearch.node.stats.indices.docs.count`*:: +*`elasticsearch.shard.primary`*:: + -- -Total number of existing documents. +True if this is the primary shard. -type: long +type: boolean -- -*`elasticsearch.node.stats.indices.docs.deleted`*:: +*`elasticsearch.shard.number`*:: + -- -Total number of deleted documents. +The number of this shard. type: long -- -*`elasticsearch.node.stats.indices.segments.count`*:: +*`elasticsearch.shard.state`*:: + -- -Total number of segments. +The state of this shard. -type: long +type: keyword -- -*`elasticsearch.node.stats.indices.segments.memory.bytes`*:: +*`elasticsearch.shard.relocating_node.name`*:: + -- -Total size of segments in bytes. - +The node the shard was relocated from. -type: long -format: bytes +type: keyword -- -*`elasticsearch.node.stats.indices.store.size.bytes`*:: -+ --- -Total size of the store in bytes. +[[exported-fields-envoyproxy]] +== envoyproxy fields +envoyproxy module -type: long --- [float] -=== jvm.mem.pools +=== envoyproxy -JVM memory pool stats [float] -=== old +=== server -Old memory pool stats. +Contains envoy proxy server stats -*`elasticsearch.node.stats.jvm.mem.pools.old.max.bytes`*:: + +*`envoyproxy.server.cluster_manager.active_clusters`*:: + -- -Max bytes. +Number of currently active (warmed) clusters -type: long -format: bytes +type: integer -- -*`elasticsearch.node.stats.jvm.mem.pools.old.peak.bytes`*:: +*`envoyproxy.server.cluster_manager.cluster_added`*:: + -- -Peak bytes. +Total clusters added (either via static config or CDS) -type: long -format: bytes +type: integer -- -*`elasticsearch.node.stats.jvm.mem.pools.old.peak_max.bytes`*:: +*`envoyproxy.server.cluster_manager.cluster_modified`*:: + -- -Peak max bytes. +Total clusters modified (via CDS) -type: long -format: bytes +type: integer -- -*`elasticsearch.node.stats.jvm.mem.pools.old.used.bytes`*:: +*`envoyproxy.server.cluster_manager.cluster_removed`*:: + -- -Used bytes. +Total clusters removed (via CDS) -type: long -format: bytes +type: integer -- -[float] -=== young +*`envoyproxy.server.cluster_manager.warming_clusters`*:: ++ +-- +Number of currently warming (not active) clusters -Young memory pool stats. +type: integer +-- -*`elasticsearch.node.stats.jvm.mem.pools.young.max.bytes`*:: +*`envoyproxy.server.cluster_manager.cluster_updated`*:: + -- -Max bytes. +Total cluster updates -type: long -format: bytes +type: integer -- -*`elasticsearch.node.stats.jvm.mem.pools.young.peak.bytes`*:: +*`envoyproxy.server.cluster_manager.cluster_updated_via_merge`*:: + -- -Peak bytes. +Total cluster updates applied as merged updates -type: long -format: bytes +type: integer -- -*`elasticsearch.node.stats.jvm.mem.pools.young.peak_max.bytes`*:: +*`envoyproxy.server.cluster_manager.update_merge_cancelled`*:: + -- -Peak max bytes. +Total merged updates that got cancelled and delivered early -type: long -format: bytes +type: integer -- -*`elasticsearch.node.stats.jvm.mem.pools.young.used.bytes`*:: +*`envoyproxy.server.cluster_manager.update_out_of_merge_window`*:: + -- -Used bytes. +Total updates which arrived out of a merge window -type: long -format: bytes +type: integer -- -[float] -=== survivor - -Survivor memory pool stats. - - -*`elasticsearch.node.stats.jvm.mem.pools.survivor.max.bytes`*:: +*`envoyproxy.server.filesystem.flushed_by_timer`*:: + -- -Max bytes. +Total number of times internal flush buffers are written to a file due to flush timeout -type: long -format: bytes +type: integer -- -*`elasticsearch.node.stats.jvm.mem.pools.survivor.peak.bytes`*:: +*`envoyproxy.server.filesystem.reopen_failed`*:: + -- -Peak bytes. +Total number of times a file was failed to be opened -type: long -format: bytes +type: integer -- -*`elasticsearch.node.stats.jvm.mem.pools.survivor.peak_max.bytes`*:: +*`envoyproxy.server.filesystem.write_buffered`*:: + -- -Peak max bytes. +Total number of times file data is moved to Envoys internal flush buffer -type: long -format: bytes +type: integer -- -*`elasticsearch.node.stats.jvm.mem.pools.survivor.used.bytes`*:: +*`envoyproxy.server.filesystem.write_completed`*:: + -- -Used bytes. +Total number of times a file was written -type: long -format: bytes +type: integer -- -[float] -=== jvm.gc.collectors - -GC collector stats. - - - -[float] -=== old.collection +*`envoyproxy.server.filesystem.write_total_buffered`*:: ++ +-- +Current total size of internal flush buffer in bytes -Old collection gc. +type: integer +-- -*`elasticsearch.node.stats.jvm.gc.collectors.old.collection.count`*:: +*`envoyproxy.server.filesystem.write_failed`*:: + -- +Total number of times an error occurred during a file write operation -type: long +type: integer -- -*`elasticsearch.node.stats.jvm.gc.collectors.old.collection.ms`*:: + +*`envoyproxy.server.runtime.load_error`*:: + -- +Total number of load attempts that resulted in an error in any layer -type: long +type: integer -- -[float] -=== young.collection +*`envoyproxy.server.runtime.load_success`*:: ++ +-- +Total number of load attempts that were successful at all layers -Young collection gc. +type: integer +-- -*`elasticsearch.node.stats.jvm.gc.collectors.young.collection.count`*:: +*`envoyproxy.server.runtime.num_keys`*:: + -- +Number of keys currently loaded -type: long +type: integer -- -*`elasticsearch.node.stats.jvm.gc.collectors.young.collection.ms`*:: +*`envoyproxy.server.runtime.override_dir_exists`*:: + -- +Total number of loads that did use an override directory -type: long +type: integer -- -[float] -=== fs.summary +*`envoyproxy.server.runtime.override_dir_not_exists`*:: ++ +-- +Total number of loads that did not use an override directory -File system summary +type: integer +-- -*`elasticsearch.node.stats.fs.summary.total.bytes`*:: +*`envoyproxy.server.runtime.admin_overrides_active`*:: + -- +1 if any admin overrides are active otherwise 0 -type: long - -format: bytes +type: integer -- -*`elasticsearch.node.stats.fs.summary.free.bytes`*:: +*`envoyproxy.server.runtime.deprecated_feature_use`*:: + -- +Total number of times deprecated features were used. -type: long - -format: bytes +type: integer -- -*`elasticsearch.node.stats.fs.summary.available.bytes`*:: +*`envoyproxy.server.runtime.num_layers`*:: + -- +Number of layers currently active (without loading errors) -type: long - -format: bytes +type: integer -- -[float] -=== cluster.pending_task -`cluster.pending_task` contains a pending task description. +*`envoyproxy.server.listener_manager.listener_added`*:: ++ +-- +Total listeners added (either via static config or LDS) +type: integer -*`elasticsearch.cluster.pending_task.insert_order`*:: +-- + +*`envoyproxy.server.listener_manager.listener_create_failure`*:: + -- -Insert order +Total failed listener object additions to workers -type: long +type: integer -- -*`elasticsearch.cluster.pending_task.priority`*:: +*`envoyproxy.server.listener_manager.listener_create_success`*:: + -- -Priority +Total listener objects successfully added to workers -type: long +type: integer -- -*`elasticsearch.cluster.pending_task.source`*:: +*`envoyproxy.server.listener_manager.listener_modified`*:: + -- -Source. For example: put-mapping +Total listeners modified (via LDS) -type: keyword +type: integer -- -*`elasticsearch.cluster.pending_task.time_in_queue.ms`*:: +*`envoyproxy.server.listener_manager.listener_removed`*:: + -- -Time in queue +Total listeners removed (via LDS) -type: long +type: integer -- -[float] -=== shard +*`envoyproxy.server.listener_manager.total_listeners_active`*:: ++ +-- +Number of currently active listeners -shard fields +type: integer +-- -*`elasticsearch.shard.primary`*:: +*`envoyproxy.server.listener_manager.total_listeners_draining`*:: + -- -True if this is the primary shard. +Number of currently draining listeners -type: boolean +type: integer -- -*`elasticsearch.shard.number`*:: +*`envoyproxy.server.listener_manager.total_listeners_warming`*:: + -- -The number of this shard. +Number of currently warming listeners -type: long +type: integer -- -*`elasticsearch.shard.state`*:: +*`envoyproxy.server.listener_manager.listener_stopped`*:: + -- -The state of this shard. +Total listeners stopped -type: keyword +type: integer -- -*`elasticsearch.shard.relocating_node.name`*:: + +*`envoyproxy.server.stats.overflow`*:: + -- -The node the shard was relocated from. +Total number of times Envoy cannot allocate a statistic due to a shortage of shared memory -type: keyword +type: integer -- -[[exported-fields-envoyproxy]] -== envoyproxy fields -envoyproxy module +*`envoyproxy.server.server.days_until_first_cert_expiring`*:: ++ +-- +Number of days until the next certificate being managed will expire +type: integer -[float] -=== envoyproxy +-- +*`envoyproxy.server.server.live`*:: ++ +-- +1 if the server is not currently draining, 0 otherwise +type: integer -[float] -=== server +-- -Contains envoy proxy server stats +*`envoyproxy.server.server.memory_allocated`*:: ++ +-- +Current amount of allocated memory in bytes +type: integer +-- -*`envoyproxy.server.cluster_manager.active_clusters`*:: +*`envoyproxy.server.server.memory_heap_size`*:: + -- -Number of currently active (warmed) clusters +Current reserved heap size in bytes type: integer -- -*`envoyproxy.server.cluster_manager.cluster_added`*:: +*`envoyproxy.server.server.parent_connections`*:: + -- -Total clusters added (either via static config or CDS) +Total connections of the old Envoy process on hot restart type: integer -- -*`envoyproxy.server.cluster_manager.cluster_modified`*:: +*`envoyproxy.server.server.total_connections`*:: + -- -Total clusters modified (via CDS) +Total connections of both new and old Envoy processes type: integer -- -*`envoyproxy.server.cluster_manager.cluster_removed`*:: +*`envoyproxy.server.server.uptime`*:: + -- -Total clusters removed (via CDS) +Current server uptime in seconds type: integer -- -*`envoyproxy.server.cluster_manager.warming_clusters`*:: +*`envoyproxy.server.server.version`*:: + -- -Number of currently warming (not active) clusters +Integer represented version number based on SCM revision type: integer -- -*`envoyproxy.server.cluster_manager.cluster_updated`*:: +*`envoyproxy.server.server.watchdog_mega_miss`*:: + -- -Total cluster updates +type: integer +-- +*`envoyproxy.server.server.watchdog_miss`*:: ++ +-- type: integer -- -*`envoyproxy.server.cluster_manager.cluster_updated_via_merge`*:: +*`envoyproxy.server.server.hot_restart_epoch`*:: + -- -Total cluster updates applied as merged updates +Current hot restart epoch type: integer -- -*`envoyproxy.server.cluster_manager.update_merge_cancelled`*:: +*`envoyproxy.server.server.concurrency`*:: + -- -Total merged updates that got cancelled and delivered early +Number of worker threads type: integer -- -*`envoyproxy.server.cluster_manager.update_out_of_merge_window`*:: +*`envoyproxy.server.server.debug_assertion_failures`*:: + -- -Total updates which arrived out of a merge window - - type: integer -- - -*`envoyproxy.server.filesystem.flushed_by_timer`*:: +*`envoyproxy.server.server.dynamic_unknown_fields`*:: + -- -Total number of times internal flush buffers are written to a file due to flush timeout +Number of messages in dynamic configuration with unknown fields type: integer -- -*`envoyproxy.server.filesystem.reopen_failed`*:: +*`envoyproxy.server.server.state`*:: + -- -Total number of times a file was failed to be opened +Current state of the Server type: integer -- -*`envoyproxy.server.filesystem.write_buffered`*:: +*`envoyproxy.server.server.static_unknown_fields`*:: + -- -Total number of times file data is moved to Envoys internal flush buffer +Number of messages in static configuration with unknown fields type: integer -- -*`envoyproxy.server.filesystem.write_completed`*:: +*`envoyproxy.server.server.stats_recent_lookups`*:: + -- -Total number of times a file was written - - type: integer -- -*`envoyproxy.server.filesystem.write_total_buffered`*:: + +*`envoyproxy.server.http2.header_overflow`*:: + -- -Current total size of internal flush buffer in bytes +Total number of connections reset due to the headers being larger than Envoy::Http::Http2::ConnectionImpl::StreamImpl::MAX_HEADER_SIZE (63k) type: integer -- -*`envoyproxy.server.filesystem.write_failed`*:: +*`envoyproxy.server.http2.headers_cb_no_stream`*:: + -- -Total number of times an error occurred during a file write operation +Total number of errors where a header callback is called without an associated stream. This tracks an unexpected occurrence due to an as yet undiagnosed bug type: integer -- - -*`envoyproxy.server.runtime.load_error`*:: +*`envoyproxy.server.http2.rx_messaging_error`*:: + -- -Total number of load attempts that resulted in an error in any layer +Total number of invalid received frames that violated section 8 of the HTTP/2 spec. This will result in a tx_reset type: integer -- -*`envoyproxy.server.runtime.load_success`*:: +*`envoyproxy.server.http2.rx_reset`*:: + -- -Total number of load attempts that were successful at all layers +Total number of reset stream frames received by Envoy type: integer -- -*`envoyproxy.server.runtime.num_keys`*:: +*`envoyproxy.server.http2.too_many_header_frames`*:: + -- -Number of keys currently loaded +Total number of times an HTTP2 connection is reset due to receiving too many headers frames. Envoy currently supports proxying at most one header frame for 100-Continue one non-100 response code header frame and one frame with trailers type: integer -- -*`envoyproxy.server.runtime.override_dir_exists`*:: +*`envoyproxy.server.http2.trailers`*:: + -- -Total number of loads that did use an override directory +Total number of trailers seen on requests coming from downstream type: integer -- -*`envoyproxy.server.runtime.override_dir_not_exists`*:: +*`envoyproxy.server.http2.tx_reset`*:: + -- -Total number of loads that did not use an override directory +Total number of reset stream frames transmitted by Envoy type: integer -- -*`envoyproxy.server.runtime.admin_overrides_active`*:: +[[exported-fields-etcd]] +== Etcd fields + +etcd Module + + + +[float] +=== etcd + +`etcd` contains statistics that were read from Etcd + + + +*`etcd.api_version`*:: + -- -1 if any admin overrides are active otherwise 0 +Etcd API version for metrics retrieval -type: integer +type: keyword -- -*`envoyproxy.server.runtime.deprecated_feature_use`*:: +[float] +=== leader + +Contains etcd leader statistics. + + + +[float] +=== followers.counts + +The number of failed and successful Raft RPC requests. + + + +*`etcd.leader.followers.counts.followers.counts.success`*:: + -- -Total number of times deprecated features were used. - +successful Raft RPC requests type: integer -- -*`envoyproxy.server.runtime.num_layers`*:: +*`etcd.leader.followers.counts.followers.counts.fail`*:: + -- -Number of layers currently active (without loading errors) - +failed Raft RPC requests type: integer -- +[float] +=== followers.latency -*`envoyproxy.server.listener_manager.listener_added`*:: +latency to each peer in the cluster + + + +*`etcd.leader.followers.latency.followers.latency.average`*:: + -- -Total listeners added (either via static config or LDS) +type: scaled_float +-- -type: integer +*`etcd.leader.followers.latency.followers.latency.current`*:: ++ +-- +type: scaled_float -- -*`envoyproxy.server.listener_manager.listener_create_failure`*:: +*`etcd.leader.followers.latency.followers.latency.maximum`*:: + -- -Total failed listener object additions to workers +type: scaled_float +-- +*`etcd.leader.followers.latency.followers.latency.minimum`*:: ++ +-- type: integer -- -*`envoyproxy.server.listener_manager.listener_create_success`*:: +*`etcd.leader.followers.latency.follower.latency.standardDeviation`*:: + -- -Total listener objects successfully added to workers +type: scaled_float +-- -type: integer +*`etcd.leader.leader`*:: ++ +-- +ID of actual leader + +type: keyword -- -*`envoyproxy.server.listener_manager.listener_modified`*:: +[float] +=== server + +Server metrics from the Etcd V3 /metrics endpoint + + + +*`etcd.server.has_leader`*:: + -- -Total listeners modified (via LDS) +Whether a leader exists in the cluster -type: integer +type: byte -- -*`envoyproxy.server.listener_manager.listener_removed`*:: +*`etcd.server.leader_changes.count`*:: + -- -Total listeners removed (via LDS) +Number of leader changes seen at the cluster -type: integer +type: long -- -*`envoyproxy.server.listener_manager.total_listeners_active`*:: +*`etcd.server.proposals_committed.count`*:: + -- -Number of currently active listeners +Number of consensus proposals commited -type: integer +type: long -- -*`envoyproxy.server.listener_manager.total_listeners_draining`*:: +*`etcd.server.proposals_pending.count`*:: + -- -Number of currently draining listeners +Number of consensus proposals pending -type: integer +type: long -- -*`envoyproxy.server.listener_manager.total_listeners_warming`*:: +*`etcd.server.proposals_failed.count`*:: + -- -Number of currently warming listeners +Number of consensus proposals failed -type: integer +type: long -- -*`envoyproxy.server.listener_manager.listener_stopped`*:: +*`etcd.server.grpc_started.count`*:: + -- -Total listeners stopped +Number of sent gRPC requests -type: integer +type: long -- - -*`envoyproxy.server.stats.overflow`*:: +*`etcd.server.grpc_handled.count`*:: + -- -Total number of times Envoy cannot allocate a statistic due to a shortage of shared memory +Number of received gRPC requests -type: integer +type: long -- +[float] +=== disk -*`envoyproxy.server.server.days_until_first_cert_expiring`*:: -+ --- -Number of days until the next certificate being managed will expire - +Disk metrics from the Etcd V3 /metrics endpoint -type: integer --- -*`envoyproxy.server.server.live`*:: +*`etcd.disk.mvcc_db_total_size.bytes`*:: + -- -1 if the server is not currently draining, 0 otherwise +Size of stored data at MVCC -type: integer +type: long + +format: bytes -- -*`envoyproxy.server.server.memory_allocated`*:: +*`etcd.disk.wal_fsync_duration.ns.bucket.*`*:: + -- -Current amount of allocated memory in bytes +Latency for writing ahead logs to disk -type: integer +type: object -- -*`envoyproxy.server.server.memory_heap_size`*:: +*`etcd.disk.wal_fsync_duration.ns.count`*:: + -- -Current reserved heap size in bytes +Write ahead logs count -type: integer +type: long -- -*`envoyproxy.server.server.parent_connections`*:: +*`etcd.disk.wal_fsync_duration.ns.sum`*:: + -- -Total connections of the old Envoy process on hot restart +Write ahead logs latency sum -type: integer +type: long -- -*`envoyproxy.server.server.total_connections`*:: +*`etcd.disk.backend_commit_duration.ns.bucket.*`*:: + -- -Total connections of both new and old Envoy processes +Latency for writing backend changes to disk -type: integer +type: object -- -*`envoyproxy.server.server.uptime`*:: +*`etcd.disk.backend_commit_duration.ns.count`*:: + -- -Current server uptime in seconds +Backend commits count -type: integer +type: long -- -*`envoyproxy.server.server.version`*:: +*`etcd.disk.backend_commit_duration.ns.sum`*:: + -- -Integer represented version number based on SCM revision +Backend commits latency sum -type: integer +type: long -- -*`envoyproxy.server.server.watchdog_mega_miss`*:: -+ --- -type: integer +[float] +=== memory --- +Memory metrics from the Etcd V3 /metrics endpoint -*`envoyproxy.server.server.watchdog_miss`*:: -+ --- -type: integer --- -*`envoyproxy.server.server.hot_restart_epoch`*:: +*`etcd.memory.go_memstats_alloc.bytes`*:: + -- -Current hot restart epoch +Memory allocated bytes as of MemStats Go -type: integer +type: long --- +format: bytes -*`envoyproxy.server.server.concurrency`*:: -+ -- -Number of worker threads +[float] +=== network -type: integer +Network metrics from the Etcd V3 /metrics endpoint --- -*`envoyproxy.server.server.debug_assertion_failures`*:: + +*`etcd.network.client_grpc_sent.bytes`*:: + -- -type: integer +gRPC sent bytes total + + +type: long + +format: bytes -- -*`envoyproxy.server.server.dynamic_unknown_fields`*:: +*`etcd.network.client_grpc_received.bytes`*:: + -- -Number of messages in dynamic configuration with unknown fields +gRPC received bytes total -type: integer +type: long --- +format: bytes -*`envoyproxy.server.server.state`*:: -+ -- -Current state of the Server +[float] +=== self + +Contains etcd self statistics. -type: integer --- -*`envoyproxy.server.server.static_unknown_fields`*:: +*`etcd.self.id`*:: + -- -Number of messages in static configuration with unknown fields +the unique identifier for the member -type: integer +type: keyword -- -*`envoyproxy.server.server.stats_recent_lookups`*:: +*`etcd.self.leaderinfo.leader`*:: + -- -type: integer +id of the current leader member --- +type: keyword -*`envoyproxy.server.http2.header_overflow`*:: +-- + +*`etcd.self.leaderinfo.starttime`*:: + -- -Total number of connections reset due to the headers being larger than Envoy::Http::Http2::ConnectionImpl::StreamImpl::MAX_HEADER_SIZE (63k) +the time when this node was started -type: integer +type: keyword -- -*`envoyproxy.server.http2.headers_cb_no_stream`*:: +*`etcd.self.leaderinfo.uptime`*:: + -- -Total number of errors where a header callback is called without an associated stream. This tracks an unexpected occurrence due to an as yet undiagnosed bug +amount of time the leader has been leader -type: integer +type: keyword -- -*`envoyproxy.server.http2.rx_messaging_error`*:: +*`etcd.self.name`*:: + -- -Total number of invalid received frames that violated section 8 of the HTTP/2 spec. This will result in a tx_reset +this member's name -type: integer +type: keyword -- -*`envoyproxy.server.http2.rx_reset`*:: +*`etcd.self.recv.appendrequest.count`*:: + -- -Total number of reset stream frames received by Envoy +number of append requests this node has processed type: integer -- -*`envoyproxy.server.http2.too_many_header_frames`*:: +*`etcd.self.recv.bandwidthrate`*:: + -- -Total number of times an HTTP2 connection is reset due to receiving too many headers frames. Envoy currently supports proxying at most one header frame for 100-Continue one non-100 response code header frame and one frame with trailers +number of bytes per second this node is receiving (follower only) -type: integer +type: scaled_float -- -*`envoyproxy.server.http2.trailers`*:: +*`etcd.self.recv.pkgrate`*:: + -- -Total number of trailers seen on requests coming from downstream +number of requests per second this node is receiving (follower only) -type: integer +type: scaled_float -- -*`envoyproxy.server.http2.tx_reset`*:: +*`etcd.self.send.appendrequest.count`*:: + -- -Total number of reset stream frames transmitted by Envoy +number of requests that this node has sent type: integer -- -[[exported-fields-etcd]] -== Etcd fields +*`etcd.self.send.bandwidthrate`*:: ++ +-- +number of bytes per second this node is sending (leader only). This value is undefined on single member clusters. -etcd Module +type: scaled_float +-- -[float] -=== etcd +*`etcd.self.send.pkgrate`*:: ++ +-- +number of requests per second this node is sending (leader only). This value is undefined on single member clusters. -`etcd` contains statistics that were read from Etcd +type: scaled_float +-- -*`etcd.api_version`*:: +*`etcd.self.starttime`*:: + -- -Etcd API version for metrics retrieval +the time when this node was started type: keyword -- -[float] -=== leader +*`etcd.self.state`*:: ++ +-- +either leader or follower -Contains etcd leader statistics. +type: keyword +-- [float] -=== followers.counts - -The number of failed and successful Raft RPC requests. - - +=== store -*`etcd.leader.followers.counts.followers.counts.success`*:: -+ --- -successful Raft RPC requests +The store statistics include information about the operations that this node has handled. -type: integer --- -*`etcd.leader.followers.counts.followers.counts.fail`*:: +*`etcd.store.gets.success`*:: + -- -failed Raft RPC requests - type: integer -- -[float] -=== followers.latency - -latency to each peer in the cluster - - - -*`etcd.leader.followers.latency.followers.latency.average`*:: +*`etcd.store.gets.fail`*:: + -- -type: scaled_float +type: integer -- -*`etcd.leader.followers.latency.followers.latency.current`*:: +*`etcd.store.sets.success`*:: + -- -type: scaled_float +type: integer -- -*`etcd.leader.followers.latency.followers.latency.maximum`*:: +*`etcd.store.sets.fail`*:: + -- -type: scaled_float +type: integer -- -*`etcd.leader.followers.latency.followers.latency.minimum`*:: +*`etcd.store.delete.success`*:: + -- type: integer -- -*`etcd.leader.followers.latency.follower.latency.standardDeviation`*:: +*`etcd.store.delete.fail`*:: + -- -type: scaled_float +type: integer -- -*`etcd.leader.leader`*:: +*`etcd.store.update.success`*:: + -- -ID of actual leader - -type: keyword +type: integer -- -[float] -=== server - -Server metrics from the Etcd V3 /metrics endpoint - - - -*`etcd.server.has_leader`*:: +*`etcd.store.update.fail`*:: + -- -Whether a leader exists in the cluster - - -type: byte +type: integer -- -*`etcd.server.leader_changes.count`*:: +*`etcd.store.create.success`*:: + -- -Number of leader changes seen at the cluster - - -type: long +type: integer -- -*`etcd.server.proposals_committed.count`*:: +*`etcd.store.create.fail`*:: + -- -Number of consensus proposals commited - - -type: long +type: integer -- -*`etcd.server.proposals_pending.count`*:: +*`etcd.store.compareandswap.success`*:: + -- -Number of consensus proposals pending - - -type: long +type: integer -- -*`etcd.server.proposals_failed.count`*:: +*`etcd.store.compareandswap.fail`*:: + -- -Number of consensus proposals failed - - -type: long +type: integer -- -*`etcd.server.grpc_started.count`*:: +*`etcd.store.compareanddelete.success`*:: + -- -Number of sent gRPC requests - - -type: long +type: integer -- -*`etcd.server.grpc_handled.count`*:: +*`etcd.store.compareanddelete.fail`*:: + -- -Number of received gRPC requests - - -type: long +type: integer -- -[float] -=== disk - -Disk metrics from the Etcd V3 /metrics endpoint - +*`etcd.store.expire.count`*:: ++ +-- +type: integer +-- -*`etcd.disk.mvcc_db_total_size.bytes`*:: +*`etcd.store.watchers`*:: + -- -Size of stored data at MVCC +type: integer +-- -type: long +[[exported-fields-golang]] +== Golang fields -format: bytes +Golang module --- -*`etcd.disk.wal_fsync_duration.ns.bucket.*`*:: -+ --- -Latency for writing ahead logs to disk +[float] +=== golang -type: object --- -*`etcd.disk.wal_fsync_duration.ns.count`*:: -+ --- -Write ahead logs count +[float] +=== expvar -type: long +expvar --- -*`etcd.disk.wal_fsync_duration.ns.sum`*:: + +*`golang.expvar.cmdline`*:: + -- -Write ahead logs latency sum +The cmdline of this Go program start with. -type: long +type: keyword -- -*`etcd.disk.backend_commit_duration.ns.bucket.*`*:: -+ --- -Latency for writing backend changes to disk +[float] +=== heap +The Go program heap information exposed by expvar. -type: object --- -*`etcd.disk.backend_commit_duration.ns.count`*:: +*`golang.heap.cmdline`*:: + -- -Backend commits count +The cmdline of this Go program start with. -type: long +type: keyword -- -*`etcd.disk.backend_commit_duration.ns.sum`*:: -+ --- -Backend commits latency sum +[float] +=== gc +Garbage collector summary. -type: long --- [float] -=== memory +=== total_pause -Memory metrics from the Etcd V3 /metrics endpoint +Total GC pause duration over lifetime of process. -*`etcd.memory.go_memstats_alloc.bytes`*:: +*`golang.heap.gc.total_pause.ns`*:: + -- -Memory allocated bytes as of MemStats Go +Duration in Ns. type: long -format: bytes - -- -[float] -=== network - -Network metrics from the Etcd V3 /metrics endpoint - - - -*`etcd.network.client_grpc_sent.bytes`*:: +*`golang.heap.gc.total_count`*:: + -- -gRPC sent bytes total +Total number of GC was happened. type: long -format: bytes - -- -*`etcd.network.client_grpc_received.bytes`*:: +*`golang.heap.gc.next_gc_limit`*:: + -- -gRPC received bytes total +Next collection will happen when HeapAlloc > this amount. type: long @@ -13932,427 +15008,365 @@ format: bytes -- -[float] -=== self - -Contains etcd self statistics. +*`golang.heap.gc.cpu_fraction`*:: ++ +-- +Fraction of CPU time used by GC. +type: float -*`etcd.self.id`*:: -+ -- -the unique identifier for the member +[float] +=== pause -type: keyword +Last GC pause durations during the monitoring period. --- -*`etcd.self.leaderinfo.leader`*:: + +*`golang.heap.gc.pause.count`*:: + -- -id of the current leader member +Count of GC pause duration during this collect period. -type: keyword +type: long -- -*`etcd.self.leaderinfo.starttime`*:: -+ --- -the time when this node was started +[float] +=== sum +Total GC pause duration during this collect period. -type: keyword --- -*`etcd.self.leaderinfo.uptime`*:: +*`golang.heap.gc.pause.sum.ns`*:: + -- -amount of time the leader has been leader +Duration in Ns. -type: keyword +type: long -- -*`etcd.self.name`*:: -+ --- -this member's name +[float] +=== max +Max GC pause duration during this collect period. -type: keyword --- -*`etcd.self.recv.appendrequest.count`*:: +*`golang.heap.gc.pause.max.ns`*:: + -- -number of append requests this node has processed +Duration in Ns. -type: integer +type: long -- -*`etcd.self.recv.bandwidthrate`*:: -+ --- -number of bytes per second this node is receiving (follower only) +[float] +=== avg +Average GC pause duration during this collect period. -type: scaled_float --- -*`etcd.self.recv.pkgrate`*:: +*`golang.heap.gc.pause.avg.ns`*:: + -- -number of requests per second this node is receiving (follower only) +Duration in Ns. -type: scaled_float +type: long -- -*`etcd.self.send.appendrequest.count`*:: -+ --- -number of requests that this node has sent +[float] +=== system +Heap summary,which bytes was obtained from system. -type: integer --- -*`etcd.self.send.bandwidthrate`*:: +*`golang.heap.system.total`*:: + -- -number of bytes per second this node is sending (leader only). This value is undefined on single member clusters. +Total bytes obtained from system (sum of XxxSys below). -type: scaled_float +type: long + +format: bytes -- -*`etcd.self.send.pkgrate`*:: +*`golang.heap.system.obtained`*:: + -- -number of requests per second this node is sending (leader only). This value is undefined on single member clusters. +Via HeapSys, bytes obtained from system. heap_sys = heap_idle + heap_inuse. -type: scaled_float +type: long + +format: bytes -- -*`etcd.self.starttime`*:: +*`golang.heap.system.stack`*:: + -- -the time when this node was started +Bytes used by stack allocator, and these bytes was obtained from system. -type: keyword +type: long + +format: bytes -- -*`etcd.self.state`*:: +*`golang.heap.system.released`*:: + -- -either leader or follower +Bytes released to the OS. -type: keyword +type: long + +format: bytes -- [float] -=== store +=== allocations -The store statistics include information about the operations that this node has handled. +Heap allocations summary. -*`etcd.store.gets.success`*:: +*`golang.heap.allocations.mallocs`*:: + -- -type: integer +Number of mallocs. --- -*`etcd.store.gets.fail`*:: -+ --- -type: integer +type: long -- -*`etcd.store.sets.success`*:: +*`golang.heap.allocations.frees`*:: + -- -type: integer +Number of frees. --- -*`etcd.store.sets.fail`*:: -+ --- -type: integer +type: long -- -*`etcd.store.delete.success`*:: +*`golang.heap.allocations.objects`*:: + -- -type: integer +Total number of allocated objects. --- -*`etcd.store.delete.fail`*:: -+ --- -type: integer +type: long -- -*`etcd.store.update.success`*:: +*`golang.heap.allocations.total`*:: + -- -type: integer +Bytes allocated (even if freed) throughout the lifetime. --- -*`etcd.store.update.fail`*:: -+ --- -type: integer +type: long + +format: bytes -- -*`etcd.store.create.success`*:: +*`golang.heap.allocations.allocated`*:: + -- -type: integer +Bytes allocated and not yet freed (same as Alloc above). --- -*`etcd.store.create.fail`*:: -+ --- -type: integer +type: long + +format: bytes -- -*`etcd.store.compareandswap.success`*:: +*`golang.heap.allocations.idle`*:: + -- -type: integer +Bytes in idle spans. --- -*`etcd.store.compareandswap.fail`*:: -+ --- -type: integer +type: long + +format: bytes -- -*`etcd.store.compareanddelete.success`*:: +*`golang.heap.allocations.active`*:: + -- -type: integer +Bytes in non-idle span. --- -*`etcd.store.compareanddelete.fail`*:: -+ --- -type: integer +type: long --- +format: bytes -*`etcd.store.expire.count`*:: -+ -- -type: integer --- +[[exported-fields-googlecloud]] +== Google Cloud Platform fields -*`etcd.store.watchers`*:: +GCP module + + + +*`googlecloud.labels`*:: + -- -type: integer +type: object -- -[[exported-fields-golang]] -== Golang fields +[[exported-fields-graphite]] +== Graphite fields -Golang module +graphite Module [float] -=== golang +=== graphite [float] -=== expvar +=== server -expvar +server -*`golang.expvar.cmdline`*:: +*`graphite.server.example`*:: + -- -The cmdline of this Go program start with. +Example field type: keyword -- -[float] -=== heap - -The Go program heap information exposed by expvar. - - - -*`golang.heap.cmdline`*:: -+ --- -The cmdline of this Go program start with. +[[exported-fields-haproxy]] +== HAProxy fields +HAProxy Module -type: keyword --- [float] -=== gc +=== haproxy -Garbage collector summary. +HAProxy metrics. [float] -=== total_pause +=== info -Total GC pause duration over lifetime of process. +General information about HAProxy processes. -*`golang.heap.gc.total_pause.ns`*:: +*`haproxy.info.processes`*:: + -- -Duration in Ns. +Number of processes. type: long -- -*`golang.heap.gc.total_count`*:: +*`haproxy.info.process_num`*:: + -- -Total number of GC was happened. +Process number. type: long -- -*`golang.heap.gc.next_gc_limit`*:: +*`haproxy.info.pid`*:: + -- -Next collection will happen when HeapAlloc > this amount. +Process ID. -type: long +type: alias -format: bytes +alias to: process.pid -- -*`golang.heap.gc.cpu_fraction`*:: +*`haproxy.info.run_queue`*:: + -- -Fraction of CPU time used by GC. -type: float +type: long -- -[float] -=== pause - -Last GC pause durations during the monitoring period. - - - -*`golang.heap.gc.pause.count`*:: +*`haproxy.info.tasks`*:: + -- -Count of GC pause duration during this collect period. type: long -- -[float] -=== sum - -Total GC pause duration during this collect period. - - - -*`golang.heap.gc.pause.sum.ns`*:: +*`haproxy.info.uptime.sec`*:: + -- -Duration in Ns. +Current uptime in seconds. type: long -- -[float] -=== max - -Max GC pause duration during this collect period. - - - -*`golang.heap.gc.pause.max.ns`*:: +*`haproxy.info.memory.max.bytes`*:: + -- -Duration in Ns. +Maximum amount of memory usage in bytes (the 'Memmax_MB' value converted to bytes). type: long --- - -[float] -=== avg - -Average GC pause duration during this collect period. - +format: bytes +-- -*`golang.heap.gc.pause.avg.ns`*:: +*`haproxy.info.ulimit_n`*:: + -- -Duration in Ns. +Maximum number of open files for the process. type: long @@ -14360,806 +15374,786 @@ type: long -- [float] -=== system - -Heap summary,which bytes was obtained from system. +=== compress -*`golang.heap.system.total`*:: -+ --- -Total bytes obtained from system (sum of XxxSys below). +[float] +=== bps -type: long -format: bytes --- -*`golang.heap.system.obtained`*:: +*`haproxy.info.compress.bps.in`*:: + -- -Via HeapSys, bytes obtained from system. heap_sys = heap_idle + heap_inuse. type: long -format: bytes - -- -*`golang.heap.system.stack`*:: +*`haproxy.info.compress.bps.out`*:: + -- -Bytes used by stack allocator, and these bytes was obtained from system. - -type: long -format: bytes +type: long -- -*`golang.heap.system.released`*:: +*`haproxy.info.compress.bps.rate_limit`*:: + -- -Bytes released to the OS. type: long -format: bytes - -- [float] -=== allocations +=== connection -Heap allocations summary. -*`golang.heap.allocations.mallocs`*:: -+ --- -Number of mallocs. +[float] +=== rate -type: long --- -*`golang.heap.allocations.frees`*:: +*`haproxy.info.connection.rate.value`*:: + -- -Number of frees. type: long -- -*`golang.heap.allocations.objects`*:: +*`haproxy.info.connection.rate.limit`*:: + -- -Total number of allocated objects. type: long -- -*`golang.heap.allocations.total`*:: +*`haproxy.info.connection.rate.max`*:: + -- -Bytes allocated (even if freed) throughout the lifetime. type: long -format: bytes - -- -*`golang.heap.allocations.allocated`*:: +*`haproxy.info.connection.current`*:: + -- -Bytes allocated and not yet freed (same as Alloc above). +Current connections. type: long -format: bytes - -- -*`golang.heap.allocations.idle`*:: +*`haproxy.info.connection.total`*:: + -- -Bytes in idle spans. +Total connections. type: long -format: bytes - -- -*`golang.heap.allocations.active`*:: +*`haproxy.info.connection.ssl.current`*:: + -- -Bytes in non-idle span. +Current SSL connections. type: long -format: bytes - -- -[[exported-fields-googlecloud]] -== Google Cloud Platform fields - -GCP module +*`haproxy.info.connection.ssl.total`*:: ++ +-- +Total SSL connections. +type: long -*`googlecloud.labels`*:: -+ -- -type: object +*`haproxy.info.connection.ssl.max`*:: ++ -- +Maximum SSL connections. -[[exported-fields-graphite]] -== Graphite fields - -graphite Module +type: long +-- -[float] -=== graphite +*`haproxy.info.connection.max`*:: ++ +-- +Maximum connections. +type: long +-- -[float] -=== server +*`haproxy.info.connection.hard_max`*:: ++ +-- -server +type: long +-- -*`graphite.server.example`*:: +*`haproxy.info.requests.total`*:: + -- -Example field -type: keyword +type: long -- -[[exported-fields-haproxy]] -== HAProxy fields +*`haproxy.info.sockets.max`*:: ++ +-- -HAProxy Module +type: long +-- -[float] -=== haproxy +*`haproxy.info.requests.max`*:: ++ +-- -HAProxy metrics. +type: long +-- [float] -=== info +=== pipes -General information about HAProxy processes. -*`haproxy.info.processes`*:: +*`haproxy.info.pipes.used`*:: + -- -Number of processes. -type: long +type: integer -- -*`haproxy.info.process_num`*:: +*`haproxy.info.pipes.free`*:: + -- -Process number. -type: long +type: integer -- -*`haproxy.info.pid`*:: +*`haproxy.info.pipes.max`*:: + -- -Process ID. -type: alias - -alias to: process.pid +type: integer -- -*`haproxy.info.run_queue`*:: +[float] +=== session + +None + + +*`haproxy.info.session.rate.value`*:: + -- -type: long +type: integer -- -*`haproxy.info.tasks`*:: +*`haproxy.info.session.rate.limit`*:: + -- -type: long +type: integer -- -*`haproxy.info.uptime.sec`*:: +*`haproxy.info.session.rate.max`*:: + -- -Current uptime in seconds. -type: long +type: integer -- -*`haproxy.info.memory.max.bytes`*:: -+ --- -Maximum amount of memory usage in bytes (the 'Memmax_MB' value converted to bytes). +[float] +=== ssl +None -type: long -format: bytes +*`haproxy.info.ssl.rate.value`*:: ++ +-- +None + +type: integer -- -*`haproxy.info.ulimit_n`*:: +*`haproxy.info.ssl.rate.limit`*:: + -- -Maximum number of open files for the process. - +None -type: long +type: integer -- -[float] -=== compress - +*`haproxy.info.ssl.rate.max`*:: ++ +-- +None +type: integer +-- [float] -=== bps - +=== frontend +None -*`haproxy.info.compress.bps.in`*:: +*`haproxy.info.ssl.frontend.key_rate.value`*:: + -- +None - -type: long +type: integer -- -*`haproxy.info.compress.bps.out`*:: +*`haproxy.info.ssl.frontend.key_rate.max`*:: + -- +None - -type: long +type: integer -- -*`haproxy.info.compress.bps.rate_limit`*:: +*`haproxy.info.ssl.frontend.session_reuse.pct`*:: + -- +None +type: scaled_float -type: long +format: percent -- [float] -=== connection - - +=== backend +None -[float] -=== rate +*`haproxy.info.ssl.backend.key_rate.value`*:: ++ +-- +None +type: integer +-- -*`haproxy.info.connection.rate.value`*:: +*`haproxy.info.ssl.backend.key_rate.max`*:: + -- +MaxConnRate - -type: long +type: integer -- -*`haproxy.info.connection.rate.limit`*:: +*`haproxy.info.ssl.cached_lookups`*:: + -- - +None type: long -- -*`haproxy.info.connection.rate.max`*:: +*`haproxy.info.ssl.cache_misses`*:: + -- - +None type: long -- -*`haproxy.info.connection.current`*:: -+ --- -Current connections. +[float] +=== zlib_mem_usage -type: long --- -*`haproxy.info.connection.total`*:: +*`haproxy.info.zlib_mem_usage.value`*:: + -- -Total connections. -type: long +type: integer -- -*`haproxy.info.connection.ssl.current`*:: +*`haproxy.info.zlib_mem_usage.max`*:: + -- -Current SSL connections. -type: long +type: integer -- -*`haproxy.info.connection.ssl.total`*:: +*`haproxy.info.idle.pct`*:: + -- -Total SSL connections. -type: long +type: scaled_float --- +format: percent -*`haproxy.info.connection.ssl.max`*:: -+ -- -Maximum SSL connections. +[float] +=== stat + +Stats collected from HAProxy processes. -type: long --- -*`haproxy.info.connection.max`*:: +*`haproxy.stat.status`*:: + -- -Maximum connections. +Status (UP, DOWN, NOLB, MAINT, or MAINT(via)...). -type: long +type: keyword -- -*`haproxy.info.connection.hard_max`*:: +*`haproxy.stat.weight`*:: + -- +Total weight (for backends), or server weight (for servers). type: long -- -*`haproxy.info.requests.total`*:: +*`haproxy.stat.downtime`*:: + -- +Total downtime (in seconds). For backends, this value is the downtime for the whole backend, not the sum of the downtime for the servers. type: long -- -*`haproxy.info.sockets.max`*:: +*`haproxy.stat.component_type`*:: + -- +Component type (0=frontend, 1=backend, 2=server, or 3=socket/listener). -type: long +type: integer -- -*`haproxy.info.requests.max`*:: +*`haproxy.stat.process_id`*:: + -- +Process ID (0 for first instance, 1 for second, and so on). -type: long +type: alias + +alias to: process.pid -- -[float] -=== pipes +*`haproxy.stat.service_name`*:: ++ +-- +Service name (FRONTEND for frontend, BACKEND for backend, or any name for server/listener). +type: keyword +-- -*`haproxy.info.pipes.used`*:: +*`haproxy.stat.in.bytes`*:: + -- +Bytes in. -type: integer +type: long + +format: bytes -- -*`haproxy.info.pipes.free`*:: +*`haproxy.stat.out.bytes`*:: + -- +Bytes out. -type: integer +type: long + +format: bytes -- -*`haproxy.info.pipes.max`*:: +*`haproxy.stat.last_change`*:: + -- +Number of seconds since the last UP->DOWN or DOWN->UP transition. type: integer -- -[float] -=== session - -None - - -*`haproxy.info.session.rate.value`*:: +*`haproxy.stat.throttle.pct`*:: + -- +Current throttle percentage for the server when slowstart is active, or no value if slowstart is inactive. -type: integer +type: scaled_float + +format: percent -- -*`haproxy.info.session.rate.limit`*:: +*`haproxy.stat.selected.total`*:: + -- +Total number of times a server was selected, either for new sessions, or when re-dispatching. For servers, this field reports the the number of times the server was selected. -type: integer +type: long -- -*`haproxy.info.session.rate.max`*:: +*`haproxy.stat.tracked.id`*:: + -- +ID of the proxy/server if tracking is enabled. -type: integer +type: long -- -[float] -=== ssl - -None - -*`haproxy.info.ssl.rate.value`*:: +*`haproxy.stat.connection.total`*:: + -- -None +Cumulative number of connections. -type: integer + +type: long -- -*`haproxy.info.ssl.rate.limit`*:: +*`haproxy.stat.connection.retried`*:: + -- -None +Number of times a connection to a server was retried. -type: integer + +type: long -- -*`haproxy.info.ssl.rate.max`*:: +*`haproxy.stat.connection.time.avg`*:: + -- -None - -type: integer +Average connect time in ms over the last 1024 requests. --- -[float] -=== frontend +type: long -None +-- -*`haproxy.info.ssl.frontend.key_rate.value`*:: +*`haproxy.stat.request.denied`*:: + -- -None - -type: integer +Requests denied because of security concerns. --- + * For TCP this is because of a matched tcp-request content rule. + * For HTTP this is because of a matched http-request or tarpit rule. -*`haproxy.info.ssl.frontend.key_rate.max`*:: -+ --- -None -type: integer +type: long -- -*`haproxy.info.ssl.frontend.session_reuse.pct`*:: +*`haproxy.stat.request.queued.current`*:: + -- -None +Current queued requests. For backends, this field reports the number of requests queued without a server assigned. -type: scaled_float -format: percent +type: long -- -[float] -=== backend - -None - - -*`haproxy.info.ssl.backend.key_rate.value`*:: +*`haproxy.stat.request.queued.max`*:: + -- -None +Maximum value of queued.current. -type: integer + +type: long -- -*`haproxy.info.ssl.backend.key_rate.max`*:: +*`haproxy.stat.request.errors`*:: + -- -MaxConnRate +Request errors. Some of the possible causes are: -type: integer + * early termination from the client, before the request has been sent + * read error from the client + * client timeout + * client closed connection + * various bad requests from the client. + * request was tarpitted. + + +type: long -- -*`haproxy.info.ssl.cached_lookups`*:: +*`haproxy.stat.request.redispatched`*:: + -- -None +Number of times a request was redispatched to another server. For servers, this field reports the number of times the server was switched away from. + type: long -- -*`haproxy.info.ssl.cache_misses`*:: +*`haproxy.stat.request.connection.errors`*:: + -- -None +Number of requests that encountered an error trying to connect to a server. For backends, this field reports the sum of the stat for all backend servers, plus any connection errors not associated with a particular server (such as the backend having no active servers). + type: long -- [float] -=== zlib_mem_usage +=== rate -*`haproxy.info.zlib_mem_usage.value`*:: +*`haproxy.stat.request.rate.value`*:: + -- +Number of HTTP requests per second over the last elapsed second. -type: integer +type: long -- -*`haproxy.info.zlib_mem_usage.max`*:: +*`haproxy.stat.request.rate.max`*:: + -- +Maximum number of HTTP requests per second. -type: integer +type: long -- -*`haproxy.info.idle.pct`*:: +*`haproxy.stat.request.total`*:: + -- +Total number of HTTP requests received. -type: scaled_float - -format: percent +type: long -- -[float] -=== stat - -Stats collected from HAProxy processes. - - -*`haproxy.stat.status`*:: +*`haproxy.stat.response.errors`*:: + -- -Status (UP, DOWN, NOLB, MAINT, or MAINT(via)...). +Number of response errors. This value includes the number of data transfers aborted by the server (haproxy.stat.server.aborted). Some other errors are: +* write errors on the client socket (won't be counted for the server stat) * failure applying filters to the response -type: keyword +type: long -- -*`haproxy.stat.weight`*:: +*`haproxy.stat.response.time.avg`*:: + -- -Total weight (for backends), or server weight (for servers). +Average response time in ms over the last 1024 requests (0 for TCP). type: long -- -*`haproxy.stat.downtime`*:: +*`haproxy.stat.response.denied`*:: + -- -Total downtime (in seconds). For backends, this value is the downtime for the whole backend, not the sum of the downtime for the servers. +Responses denied because of security concerns. For HTTP this is because of a matched http-request rule, or "option checkcache". -type: long +type: integer -- -*`haproxy.stat.component_type`*:: +[float] +=== http + + + + +*`haproxy.stat.response.http.1xx`*:: + -- -Component type (0=frontend, 1=backend, 2=server, or 3=socket/listener). +HTTP responses with 1xx code. -type: integer +type: long -- -*`haproxy.stat.process_id`*:: +*`haproxy.stat.response.http.2xx`*:: + -- -Process ID (0 for first instance, 1 for second, and so on). - +HTTP responses with 2xx code. -type: alias -alias to: process.pid +type: long -- -*`haproxy.stat.service_name`*:: +*`haproxy.stat.response.http.3xx`*:: + -- -Service name (FRONTEND for frontend, BACKEND for backend, or any name for server/listener). +HTTP responses with 3xx code. -type: keyword +type: long -- -*`haproxy.stat.in.bytes`*:: +*`haproxy.stat.response.http.4xx`*:: + -- -Bytes in. +HTTP responses with 4xx code. type: long -format: bytes - -- -*`haproxy.stat.out.bytes`*:: +*`haproxy.stat.response.http.5xx`*:: + -- -Bytes out. +HTTP responses with 5xx code. type: long -format: bytes - -- -*`haproxy.stat.last_change`*:: +*`haproxy.stat.response.http.other`*:: + -- -Number of seconds since the last UP->DOWN or DOWN->UP transition. +HTTP responses with other codes (protocol error). -type: integer +type: long -- -*`haproxy.stat.throttle.pct`*:: + +*`haproxy.stat.session.current`*:: + -- -Current throttle percentage for the server when slowstart is active, or no value if slowstart is inactive. - +Number of current sessions. -type: scaled_float -format: percent +type: long -- -*`haproxy.stat.selected.total`*:: +*`haproxy.stat.session.max`*:: + -- -Total number of times a server was selected, either for new sessions, or when re-dispatching. For servers, this field reports the the number of times the server was selected. +Maximum number of sessions. type: long -- -*`haproxy.stat.tracked.id`*:: +*`haproxy.stat.session.limit`*:: + -- -ID of the proxy/server if tracking is enabled. +Configured session limit. type: long @@ -15167,169 +16161,188 @@ type: long -- -*`haproxy.stat.connection.total`*:: +*`haproxy.stat.session.rate.value`*:: + -- -Cumulative number of connections. +Number of sessions per second over the last elapsed second. -type: long +type: integer -- -*`haproxy.stat.connection.retried`*:: +*`haproxy.stat.session.rate.limit`*:: + -- -Number of times a connection to a server was retried. +Configured limit on new sessions per second. -type: long +type: integer -- -*`haproxy.stat.connection.time.avg`*:: +*`haproxy.stat.session.rate.max`*:: + -- -Average connect time in ms over the last 1024 requests. +Maximum number of new sessions per second. -type: long +type: integer -- +[float] +=== check -*`haproxy.stat.request.denied`*:: + + + +*`haproxy.stat.check.status`*:: + -- -Requests denied because of security concerns. +Status of the last health check. One of: - * For TCP this is because of a matched tcp-request content rule. - * For HTTP this is because of a matched http-request or tarpit rule. + UNK -> unknown + INI -> initializing + SOCKERR -> socket error + L4OK -> check passed on layer 4, no upper layers testing enabled + L4TOUT -> layer 1-4 timeout + L4CON -> layer 1-4 connection problem, for example + "Connection refused" (tcp rst) or "No route to host" (icmp) + L6OK -> check passed on layer 6 + L6TOUT -> layer 6 (SSL) timeout + L6RSP -> layer 6 invalid response - protocol error + L7OK -> check passed on layer 7 + L7OKC -> check conditionally passed on layer 7, for example 404 with + disable-on-404 + L7TOUT -> layer 7 (HTTP/SMTP) timeout + L7RSP -> layer 7 invalid response - protocol error + L7STS -> layer 7 response error, for example HTTP 5xx -type: long +type: keyword -- -*`haproxy.stat.request.queued.current`*:: +*`haproxy.stat.check.code`*:: + -- -Current queued requests. For backends, this field reports the number of requests queued without a server assigned. +Layer 5-7 code, if available. type: long -- -*`haproxy.stat.request.queued.max`*:: +*`haproxy.stat.check.duration`*:: + -- -Maximum value of queued.current. +Time in ms that it took to finish the last health check. type: long -- -*`haproxy.stat.request.errors`*:: +*`haproxy.stat.check.health.last`*:: + -- -Request errors. Some of the possible causes are: - - * early termination from the client, before the request has been sent - * read error from the client - * client timeout - * client closed connection - * various bad requests from the client. - * request was tarpitted. +The result of the last health check. -type: long +type: keyword -- -*`haproxy.stat.request.redispatched`*:: +*`haproxy.stat.check.health.fail`*:: + -- -Number of times a request was redispatched to another server. For servers, this field reports the number of times the server was switched away from. +Number of failed checks. type: long -- -*`haproxy.stat.request.connection.errors`*:: +*`haproxy.stat.check.agent.last`*:: + -- -Number of requests that encountered an error trying to connect to a server. For backends, this field reports the sum of the stat for all backend servers, plus any connection errors not associated with a particular server (such as the backend having no active servers). -type: long +type: integer -- -[float] -=== rate +*`haproxy.stat.check.failed`*:: ++ +-- +Number of checks that failed while the server was up. +type: long +-- -*`haproxy.stat.request.rate.value`*:: +*`haproxy.stat.check.down`*:: + -- -Number of HTTP requests per second over the last elapsed second. +Number of UP->DOWN transitions. For backends, this value is the number of transitions to the whole backend being down, rather than the sum of the transitions for each server. type: long -- -*`haproxy.stat.request.rate.max`*:: +*`haproxy.stat.client.aborted`*:: + -- -Maximum number of HTTP requests per second. +Number of data transfers aborted by the client. -type: long +type: integer -- -*`haproxy.stat.request.total`*:: +[float] +=== server + + + + +*`haproxy.stat.server.id`*:: + -- -Total number of HTTP requests received. +Server ID (unique inside a proxy). -type: long +type: integer -- - -*`haproxy.stat.response.errors`*:: +*`haproxy.stat.server.aborted`*:: + -- -Number of response errors. This value includes the number of data transfers aborted by the server (haproxy.stat.server.aborted). Some other errors are: -* write errors on the client socket (won't be counted for the server stat) * failure applying filters to the response +Number of data transfers aborted by the server. This value is included in haproxy.stat.response.errors. -type: long +type: integer -- -*`haproxy.stat.response.time.avg`*:: +*`haproxy.stat.server.active`*:: + -- -Average response time in ms over the last 1024 requests (0 for TCP). +Number of backend servers that are active, meaning that they are healthy and can receive requests from the load balancer. -type: long +type: integer -- -*`haproxy.stat.response.denied`*:: +*`haproxy.stat.server.backup`*:: + -- -Responses denied because of security concerns. For HTTP this is because of a matched http-request rule, or "option checkcache". +Number of backend servers that are backup servers. type: integer @@ -15337,529 +16350,556 @@ type: integer -- [float] -=== http +=== compressor -*`haproxy.stat.response.http.1xx`*:: +*`haproxy.stat.compressor.in.bytes`*:: + -- -HTTP responses with 1xx code. +Number of HTTP response bytes fed to the compressor. type: long +format: bytes + -- -*`haproxy.stat.response.http.2xx`*:: +*`haproxy.stat.compressor.out.bytes`*:: + -- -HTTP responses with 2xx code. +Number of HTTP response bytes emitted by the compressor. -type: long +type: integer + +format: bytes -- -*`haproxy.stat.response.http.3xx`*:: +*`haproxy.stat.compressor.bypassed.bytes`*:: + -- -HTTP responses with 3xx code. +Number of bytes that bypassed the HTTP compressor (CPU/BW limit). type: long +format: bytes + -- -*`haproxy.stat.response.http.4xx`*:: +*`haproxy.stat.compressor.response.bytes`*:: + -- -HTTP responses with 4xx code. +Number of HTTP responses that were compressed. type: long +format: bytes + -- -*`haproxy.stat.response.http.5xx`*:: +[float] +=== proxy + + + + +*`haproxy.stat.proxy.id`*:: + -- -HTTP responses with 5xx code. +Unique proxy ID. -type: long +type: integer -- -*`haproxy.stat.response.http.other`*:: +*`haproxy.stat.proxy.name`*:: + -- -HTTP responses with other codes (protocol error). +Proxy name. -type: long +type: keyword -- +[float] +=== queue -*`haproxy.stat.session.current`*:: + + + +*`haproxy.stat.queue.limit`*:: + -- -Number of current sessions. +Configured queue limit (maxqueue) for the server, or nothing if the value of maxqueue is 0 (meaning no limit). -type: long +type: integer -- -*`haproxy.stat.session.max`*:: +*`haproxy.stat.queue.time.avg`*:: + -- -Maximum number of sessions. +The average queue time in ms over the last 1024 requests. -type: long +type: integer -- -*`haproxy.stat.session.limit`*:: -+ --- -Configured session limit. +[[exported-fields-host-processor]] +== Host fields +Info collected for the host machine. -type: long --- -*`haproxy.stat.session.rate.value`*:: +*`host.containerized`*:: + -- -Number of sessions per second over the last elapsed second. +If the host is a container. -type: integer +type: boolean -- -*`haproxy.stat.session.rate.limit`*:: +*`host.os.build`*:: + -- -Configured limit on new sessions per second. +OS build information. -type: integer +type: keyword + +example: 18D109 -- -*`haproxy.stat.session.rate.max`*:: +*`host.os.codename`*:: + -- -Maximum number of new sessions per second. +OS codename, if any. -type: integer +type: keyword --- +example: stretch -[float] -=== check +-- +[[exported-fields-http]] +== HTTP fields +HTTP module -*`haproxy.stat.check.status`*:: -+ --- -Status of the last health check. One of: - UNK -> unknown - INI -> initializing - SOCKERR -> socket error - L4OK -> check passed on layer 4, no upper layers testing enabled - L4TOUT -> layer 1-4 timeout - L4CON -> layer 1-4 connection problem, for example - "Connection refused" (tcp rst) or "No route to host" (icmp) - L6OK -> check passed on layer 6 - L6TOUT -> layer 6 (SSL) timeout - L6RSP -> layer 6 invalid response - protocol error - L7OK -> check passed on layer 7 - L7OKC -> check conditionally passed on layer 7, for example 404 with - disable-on-404 - L7TOUT -> layer 7 (HTTP/SMTP) timeout - L7RSP -> layer 7 invalid response - protocol error - L7STS -> layer 7 response error, for example HTTP 5xx +[float] +=== http -type: keyword --- -*`haproxy.stat.check.code`*:: +[float] +=== request + +HTTP request information + + + +*`http.request.headers`*:: + -- -Layer 5-7 code, if available. +The HTTP headers sent -type: long +type: object -- -*`haproxy.stat.check.duration`*:: +[float] +=== response + +HTTP response information + + + +*`http.response.headers`*:: + -- -Time in ms that it took to finish the last health check. +The HTTP headers received -type: long +type: object -- -*`haproxy.stat.check.health.last`*:: +*`http.response.code`*:: + -- -The result of the last health check. +The HTTP status code type: keyword +example: 404 + -- -*`haproxy.stat.check.health.fail`*:: +*`http.response.phrase`*:: + -- -Number of failed checks. +The HTTP status phrase -type: long +type: keyword --- +example: Not found -*`haproxy.stat.check.agent.last`*:: -+ -- +[float] +=== json -type: integer +json metricset --- -*`haproxy.stat.check.failed`*:: -+ --- -Number of checks that failed while the server was up. +[float] +=== server +server -type: long --- +[[exported-fields-ibmmq]] +== IBM MQ fields -*`haproxy.stat.check.down`*:: -+ --- -Number of UP->DOWN transitions. For backends, this value is the number of transitions to the whole backend being down, rather than the sum of the transitions for each server. +IBM MQ module -type: long --- -*`haproxy.stat.client.aborted`*:: -+ --- -Number of data transfers aborted by the client. +[[exported-fields-istio]] +== istio fields +istio Module -type: integer --- [float] -=== server +=== istio +`istio` contains statistics that were read from Istio -*`haproxy.stat.server.id`*:: -+ --- -Server ID (unique inside a proxy). +[float] +=== mesh +Contains statistics related to the Istio mesh service -type: integer --- -*`haproxy.stat.server.aborted`*:: +*`istio.mesh.instance`*:: + -- -Number of data transfers aborted by the server. This value is included in haproxy.stat.response.errors. +The prometheus instance -type: integer +type: text -- -*`haproxy.stat.server.active`*:: +*`istio.mesh.job`*:: + -- -Number of backend servers that are active, meaning that they are healthy and can receive requests from the load balancer. +The prometheus job -type: integer +type: keyword -- -*`haproxy.stat.server.backup`*:: +*`istio.mesh.requests`*:: + -- -Number of backend servers that are backup servers. +Total requests handled by an Istio proxy -type: integer +type: long -- -[float] -=== compressor +*`istio.mesh.request.duration.ms.bucket.*`*:: ++ +-- +Request duration histogram buckets in milliseconds +type: object +-- -*`haproxy.stat.compressor.in.bytes`*:: +*`istio.mesh.request.duration.ms.sum`*:: + -- -Number of HTTP response bytes fed to the compressor. +Requests duration, sum of durations in milliseconds type: long -format: bytes +format: duration -- -*`haproxy.stat.compressor.out.bytes`*:: +*`istio.mesh.request.duration.ms.count`*:: + -- -Number of HTTP response bytes emitted by the compressor. - +Requests duration, number of requests -type: integer -format: bytes +type: long -- -*`haproxy.stat.compressor.bypassed.bytes`*:: +*`istio.mesh.request.size.bytes.bucket.*`*:: + -- -Number of bytes that bypassed the HTTP compressor (CPU/BW limit). - +Request Size histogram buckets -type: long -format: bytes +type: object -- -*`haproxy.stat.compressor.response.bytes`*:: +*`istio.mesh.request.size.bytes.sum`*:: + -- -Number of HTTP responses that were compressed. +Request Size histogram sum type: long -format: bytes - -- -[float] -=== proxy +*`istio.mesh.request.size.bytes.count`*:: ++ +-- +Request Size histogram count +type: long +-- -*`haproxy.stat.proxy.id`*:: +*`istio.mesh.response.size.bytes.bucket.*`*:: + -- -Unique proxy ID. +Request Size histogram buckets -type: integer +type: object -- -*`haproxy.stat.proxy.name`*:: +*`istio.mesh.response.size.bytes.sum`*:: + -- -Proxy name. +Request Size histogram sum -type: keyword +type: long -- -[float] -=== queue +*`istio.mesh.response.size.bytes.count`*:: ++ +-- +Request Size histogram count +type: long +-- -*`haproxy.stat.queue.limit`*:: +*`istio.mesh.reporter`*:: + -- -Configured queue limit (maxqueue) for the server, or nothing if the value of maxqueue is 0 (meaning no limit). +Reporter identifies the reporter of the request. It is set to destination if report is from a server Istio proxy and source if report is from a client Istio proxy. -type: integer +type: keyword -- -*`haproxy.stat.queue.time.avg`*:: +*`istio.mesh.source.workload.name`*:: + -- -The average queue time in ms over the last 1024 requests. +This identifies the name of source workload which controls the source. -type: integer +type: keyword -- -[[exported-fields-host-processor]] -== Host fields - -Info collected for the host machine. +*`istio.mesh.source.workload.namespace`*:: ++ +-- +This identifies the namespace of the source workload. +type: keyword +-- -*`host.containerized`*:: +*`istio.mesh.source.principal`*:: + -- -If the host is a container. +This identifies the peer principal of the traffic source. It is set when peer authentication is used. -type: boolean +type: keyword -- -*`host.os.build`*:: +*`istio.mesh.source.app`*:: + -- -OS build information. +This identifies the source app based on app label of the source workload. type: keyword -example: 18D109 - -- -*`host.os.codename`*:: +*`istio.mesh.source.version`*:: + -- -OS codename, if any. +This identifies the version of the source workload. type: keyword -example: stretch - -- -[[exported-fields-http]] -== HTTP fields +*`istio.mesh.destination.workload.name`*:: ++ +-- +This identifies the name of destination workload. -HTTP module +type: keyword +-- -[float] -=== http +*`istio.mesh.destination.workload.namespace`*:: ++ +-- +This identifies the namespace of the destination workload. +type: keyword +-- -[float] -=== request +*`istio.mesh.destination.principal`*:: ++ +-- +This identifies the peer principal of the traffic destination. It is set when peer authentication is used. -HTTP request information +type: keyword +-- -*`http.request.headers`*:: +*`istio.mesh.destination.app`*:: + -- -The HTTP headers sent +This identifies the destination app based on app label of the destination workload.. -type: object +type: keyword -- -[float] -=== response +*`istio.mesh.destination.version`*:: ++ +-- +This identifies the version of the destination workload. -HTTP response information +type: keyword +-- -*`http.response.headers`*:: +*`istio.mesh.destination.service.host`*:: + -- -The HTTP headers received +This identifies destination service host responsible for an incoming request. -type: object +type: keyword -- -*`http.response.code`*:: +*`istio.mesh.destination.service.name`*:: + -- -The HTTP status code +This identifies the destination service name. type: keyword -example: 404 - -- -*`http.response.phrase`*:: +*`istio.mesh.destination.service.namespace`*:: + -- -The HTTP status phrase +This identifies the namespace of destination service. type: keyword -example: Not found +-- +*`istio.mesh.request.protocol`*:: ++ -- +This identifies the protocol of the request. It is set to API protocol if provided, otherwise request or connection protocol. -[float] -=== json -json metricset +type: keyword +-- -[float] -=== server +*`istio.mesh.response.code`*:: ++ +-- +This identifies the response code of the request. This label is present only on HTTP metrics. -server +type: long -[[exported-fields-ibmmq]] -== IBM MQ fields +-- -IBM MQ module +*`istio.mesh.connection.security.policy`*:: ++ +-- +This identifies the service authentication policy of the request. It is set to mutual_tls when Istio is used to make communication secure and report is from destination. It is set to unknown when report is from source since security policy cannot be properly populated. +type: keyword +-- [[exported-fields-jolokia]] == Jolokia fields @@ -20255,15 +21295,6 @@ type: ip -- -*`kubernetes.service.labels.*`*:: -+ --- -Labels for service - -type: object - --- - *`kubernetes.service.created`*:: + -- @@ -27865,6 +28896,7 @@ Stats scraped from a Prometheus endpoint. + *`prometheus.labels.*`*:: + -- @@ -27878,7 +28910,7 @@ type: object *`prometheus.metrics.*`*:: + -- -Prometheus metric - release: ga +Prometheus metric type: object @@ -30161,25 +31193,12 @@ type: long [[exported-fields-sql]] == sql fields -sql module - - - -[float] -=== sql - -`sql` fetches metrics from a SQL database - +SQL module fetches metrics from a SQL database -[float] -=== query - -query - -*`sql.query.driver`*:: +*`sql.driver`*:: + -- Driver used to execute the query. @@ -30189,7 +31208,7 @@ type: keyword -- -*`sql.query.query`*:: +*`sql.query`*:: + -- Query executed to collect metrics. @@ -30199,7 +31218,7 @@ type: keyword -- -*`sql.query.metrics.numeric.*`*:: +*`sql.metrics.numeric.*`*:: + -- Numeric metrics collected. @@ -30209,7 +31228,7 @@ type: object -- -*`sql.query.metrics.string.*`*:: +*`sql.metrics.string.*`*:: + -- Non-numeric values collected. @@ -30481,6 +31500,7 @@ Statsd module + *`statsd.*.count`*:: + -- @@ -30494,7 +31514,7 @@ type: object *`statsd.*.*`*:: + -- -Statsd metrics - release: beta +Statsd metrics type: object diff --git a/metricbeat/docs/modules/istio.asciidoc b/metricbeat/docs/modules/istio.asciidoc new file mode 100644 index 00000000000..8d9cd5fe006 --- /dev/null +++ b/metricbeat/docs/modules/istio.asciidoc @@ -0,0 +1,45 @@ +//// +This file is generated! See scripts/mage/docs_collector.go +//// + +[[metricbeat-module-istio]] +[role="xpack"] +== istio module + +beta[] + +This is the Istio module. The Istio module collects metrics from the +Istio https://istio.io/docs/tasks/observability/metrics/querying-metrics/#about-the-prometheus-add-on[prometheus exporters endpoints]. + +The default metricset is `mesh`. + +[float] +=== Compatibility + +The Istio module is tested with Istio 1.4 + + +[float] +=== Example configuration + +The istio module supports the standard configuration options that are described +in <>. Here is an example configuration: + +[source,yaml] +---- +metricbeat.modules: +- module: istio + metricsets: ["mesh"] + period: 10s + hosts: ["localhost:42422"] +---- + +[float] +=== Metricsets + +The following metricsets are available: + +* <> + +include::istio/mesh.asciidoc[] + diff --git a/metricbeat/docs/modules/istio/mesh.asciidoc b/metricbeat/docs/modules/istio/mesh.asciidoc new file mode 100644 index 00000000000..33ca6d19965 --- /dev/null +++ b/metricbeat/docs/modules/istio/mesh.asciidoc @@ -0,0 +1,23 @@ +//// +This file is generated! See scripts/mage/docs_collector.go +//// + +[[metricbeat-metricset-istio-mesh]] +=== istio mesh metricset + +beta[] + +include::../../../../x-pack/metricbeat/module/istio/mesh/_meta/docs.asciidoc[] + + +==== Fields + +For a description of each field in the metricset, see the +<> section. + +Here is an example document generated by this metricset: + +[source,json] +---- +include::../../../../x-pack/metricbeat/module/istio/mesh/_meta/data.json[] +---- diff --git a/metricbeat/docs/modules/sql.asciidoc b/metricbeat/docs/modules/sql.asciidoc index 30e5baf89da..c3f3d412ea7 100644 --- a/metricbeat/docs/modules/sql.asciidoc +++ b/metricbeat/docs/modules/sql.asciidoc @@ -8,7 +8,7 @@ This file is generated! See scripts/mage/docs_collector.go beta[] -This is the sql module that fetches metrics from a SQL database. You can define driver, datasource and SQL query. +This is the sql module that fetches metrics from a SQL database. You can define driver and SQL query. @@ -26,10 +26,9 @@ metricbeat.modules: metricsets: - query period: 10s - hosts: ["localhost"] + hosts: ["user=myuser password=mypassword dbname=mydb sslmode=disable"] driver: "postgres" - datasource: "user=myuser password=mypassword dbname=mydb sslmode=disable" sql_query: "select now()" ---- diff --git a/metricbeat/docs/modules/system.asciidoc b/metricbeat/docs/modules/system.asciidoc index 5a9da32636d..74c9c06a794 100644 --- a/metricbeat/docs/modules/system.asciidoc +++ b/metricbeat/docs/modules/system.asciidoc @@ -172,12 +172,13 @@ metricbeat.modules: #- fsstat # File system summary metrics #- raid # Raid #- socket # Sockets and connection info (linux only) + #- service # systemd service information enabled: true period: 10s processes: ['.*'] # Configure the metric types that are included by these metricsets. - cpu.metrics: ["percentages"] # The other available options are normalized_percentages and ticks. + cpu.metrics: ["percentages","normalized_percentages"] # The other available option is ticks. core.metrics: ["percentages"] # The other available option is ticks. # A list of filesystem types to ignore. The filesystem metricset will not @@ -229,6 +230,9 @@ metricbeat.modules: # Diskio configurations #diskio.include_devices: [] + + # Filter systemd services by status or sub-status + #service.state_filter: [] ---- [float] diff --git a/metricbeat/docs/modules_list.asciidoc b/metricbeat/docs/modules_list.asciidoc index 45170d67d62..c07155249a3 100644 --- a/metricbeat/docs/modules_list.asciidoc +++ b/metricbeat/docs/modules_list.asciidoc @@ -103,6 +103,8 @@ This file is generated! See scripts/mage/docs_collector.go |<> |<> beta[] |image:./images/icon-yes.png[Prebuilt dashboards are available] | .1+| .1+| |<> beta[] +|<> beta[] |image:./images/icon-no.png[No prebuilt dashboards] | +.1+| .1+| |<> beta[] |<> |image:./images/icon-no.png[No prebuilt dashboards] | .1+| .1+| |<> |<> |image:./images/icon-yes.png[Prebuilt dashboards are available] | @@ -259,6 +261,7 @@ include::modules/graphite.asciidoc[] include::modules/haproxy.asciidoc[] include::modules/http.asciidoc[] include::modules/ibmmq.asciidoc[] +include::modules/istio.asciidoc[] include::modules/jolokia.asciidoc[] include::modules/kafka.asciidoc[] include::modules/kibana.asciidoc[] diff --git a/metricbeat/module/windows/perfmon/defs_pdh_windows.go b/metricbeat/helper/windows/pdh/defs_pdh_windows.go similarity index 99% rename from metricbeat/module/windows/perfmon/defs_pdh_windows.go rename to metricbeat/helper/windows/pdh/defs_pdh_windows.go index 97f070a600a..bcc62c4ffd1 100644 --- a/metricbeat/module/windows/perfmon/defs_pdh_windows.go +++ b/metricbeat/helper/windows/pdh/defs_pdh_windows.go @@ -20,7 +20,7 @@ // +build ignore -package perfmon +package pdh /* #include diff --git a/metricbeat/module/windows/perfmon/defs_pdh_windows_386.go b/metricbeat/helper/windows/pdh/defs_pdh_windows_386.go similarity index 99% rename from metricbeat/module/windows/perfmon/defs_pdh_windows_386.go rename to metricbeat/helper/windows/pdh/defs_pdh_windows_386.go index 3995b8b9b01..e794050dcf5 100644 --- a/metricbeat/module/windows/perfmon/defs_pdh_windows_386.go +++ b/metricbeat/helper/windows/pdh/defs_pdh_windows_386.go @@ -18,7 +18,7 @@ // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo.exe -godefs defs_pdh_windows.go -package perfmon +package pdh type PdhErrno uintptr diff --git a/metricbeat/module/windows/perfmon/defs_pdh_windows_amd64.go b/metricbeat/helper/windows/pdh/defs_pdh_windows_amd64.go similarity index 99% rename from metricbeat/module/windows/perfmon/defs_pdh_windows_amd64.go rename to metricbeat/helper/windows/pdh/defs_pdh_windows_amd64.go index 3995b8b9b01..e794050dcf5 100644 --- a/metricbeat/module/windows/perfmon/defs_pdh_windows_amd64.go +++ b/metricbeat/helper/windows/pdh/defs_pdh_windows_amd64.go @@ -18,7 +18,7 @@ // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo.exe -godefs defs_pdh_windows.go -package perfmon +package pdh type PdhErrno uintptr diff --git a/metricbeat/module/windows/doc.go b/metricbeat/helper/windows/pdh/doc.go similarity index 62% rename from metricbeat/module/windows/doc.go rename to metricbeat/helper/windows/pdh/doc.go index 7068d9f2ef9..fc6ec0cd132 100644 --- a/metricbeat/module/windows/doc.go +++ b/metricbeat/helper/windows/pdh/doc.go @@ -15,7 +15,10 @@ // specific language governing permissions and limitations // under the License. -/* -Package windows is a Metricbeat module that contains MetricSets. -*/ -package windows +package pdh + +//go:generate go run mkpdh_defs.go +//go:generate go run ../run.go -cmd "go tool cgo -godefs defs_pdh_windows.go" -goarch amd64 -output defs_pdh_windows_amd64.go +//go:generate go run ../run.go -cmd "go tool cgo -godefs defs_pdh_windows.go" -goarch 386 -output defs_pdh_windows_386.go +//go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zpdh_windows.go pdh_windows.go +//go:generate gofmt -w defs_pdh_windows_amd64.go defs_pdh_windows_386.go zpdh_windows.go diff --git a/metricbeat/module/windows/perfmon/mkpdh_defs.go b/metricbeat/helper/windows/pdh/mkpdh_defs.go similarity index 99% rename from metricbeat/module/windows/perfmon/mkpdh_defs.go rename to metricbeat/helper/windows/pdh/mkpdh_defs.go index 1f30a1161fb..fd71b98bb27 100644 --- a/metricbeat/module/windows/perfmon/mkpdh_defs.go +++ b/metricbeat/helper/windows/pdh/mkpdh_defs.go @@ -48,7 +48,7 @@ const fileTemplate = ` // +build ignore -package perfmon +package pdh /* #include diff --git a/metricbeat/module/windows/perfmon/pdh_query_windows.go b/metricbeat/helper/windows/pdh/pdh_query_windows.go similarity index 89% rename from metricbeat/module/windows/perfmon/pdh_query_windows.go rename to metricbeat/helper/windows/pdh/pdh_query_windows.go index 5c5a7149d3b..c7d8f0d82bf 100644 --- a/metricbeat/module/windows/perfmon/pdh_query_windows.go +++ b/metricbeat/helper/windows/pdh/pdh_query_windows.go @@ -17,7 +17,7 @@ // +build windows -package perfmon +package pdh import ( "regexp" @@ -43,8 +43,8 @@ type Counter struct { // Query contains the pdh. type Query struct { - handle PdhQueryHandle - counters map[string]*Counter + Handle PdhQueryHandle + Counters map[string]*Counter } // CounterValue contains the performance counter values. @@ -60,42 +60,42 @@ func (q *Query) Open() error { if err != nil { return err } - q.handle = h - q.counters = make(map[string]*Counter) + q.Handle = h + q.Counters = make(map[string]*Counter) return nil } // AddEnglishCounter adds the specified counter to the query. func (q *Query) AddEnglishCounter(counterPath string) (PdhCounterHandle, error) { - h, err := PdhAddEnglishCounter(q.handle, counterPath, 0) + h, err := PdhAddEnglishCounter(q.Handle, counterPath, 0) return h, err } // AddCounter adds the specified counter to the query. -func (q *Query) AddCounter(counterPath string, counter CounterConfig, wildcard bool) error { - if _, found := q.counters[counterPath]; found { +func (q *Query) AddCounter(counterPath string, instance string, format string, wildcard bool) error { + if _, found := q.Counters[counterPath]; found { return nil } var err error var instanceName string // Extract the instance name from the counterPath. - if counter.InstanceName == "" || wildcard { + if instance == "" || wildcard { instanceName, err = matchInstanceName(counterPath) if err != nil { return err } } else { - instanceName = counter.InstanceName + instanceName = instance } - h, err := PdhAddCounter(q.handle, counterPath, 0) + h, err := PdhAddCounter(q.Handle, counterPath, 0) if err != nil { return err } - q.counters[counterPath] = &Counter{ + q.Counters[counterPath] = &Counter{ handle: h, instanceName: instanceName, - format: getPDHFormat(counter.Format), + format: getPDHFormat(format), } return nil } @@ -134,7 +134,7 @@ func (q *Query) RemoveUnusedCounters(counters []string) error { } } unused := make(map[string]*Counter) - for counterPath, counter := range q.counters { + for counterPath, counter := range q.Counters { if !matchCounter(counterPath, counters) { unused[counterPath] = counter } @@ -147,7 +147,7 @@ func (q *Query) RemoveUnusedCounters(counters []string) error { if err != nil { return err } - delete(q.counters, counterPath) + delete(q.Counters, counterPath) } return nil } @@ -163,16 +163,16 @@ func matchCounter(counterPath string, counterList []string) bool { // CollectData collects the value for all counters in the query. func (q *Query) CollectData() error { - return PdhCollectQueryData(q.handle) + return PdhCollectQueryData(q.Handle) } // GetFormattedCounterValues returns an array of formatted values for a query. func (q *Query) GetFormattedCounterValues() (map[string][]CounterValue, error) { - if q.counters == nil || len(q.counters) == 0 { + if q.Counters == nil || len(q.Counters) == 0 { return nil, errors.New("no counter list found") } - rtn := make(map[string][]CounterValue, len(q.counters)) - for path, counter := range q.counters { + rtn := make(map[string][]CounterValue, len(q.Counters)) + for path, counter := range q.Counters { rtn[path] = append(rtn[path], getCounterValue(counter)) } return rtn, nil @@ -206,7 +206,7 @@ func (q *Query) ExpandWildCardPath(wildCardPath string) ([]string, error) { // Close closes the query and all of its counters. func (q *Query) Close() error { - return PdhCloseQuery(q.handle) + return PdhCloseQuery(q.Handle) } // matchInstanceName will check first for instance and then for any objects names. diff --git a/metricbeat/module/windows/perfmon/pdh_query_windows_test.go b/metricbeat/helper/windows/pdh/pdh_query_windows_test.go similarity index 94% rename from metricbeat/module/windows/perfmon/pdh_query_windows_test.go rename to metricbeat/helper/windows/pdh/pdh_query_windows_test.go index 4e45ec82718..2b5038e42c4 100644 --- a/metricbeat/module/windows/perfmon/pdh_query_windows_test.go +++ b/metricbeat/helper/windows/pdh/pdh_query_windows_test.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package perfmon +package pdh import ( "syscall" @@ -38,8 +38,7 @@ func TestAddCounterInvalidArgWhenQueryClosed(t *testing.T) { queryPath, err := q.GetCounterPaths(validQuery) // if windows os language is ENG then err will be nil, else the GetCounterPaths will execute the AddCounter if assert.NoError(t, err) { - counter := CounterConfig{Format: "float", InstanceName: "TestInstanceName"} - err = q.AddCounter(queryPath[0], counter, false) + err = q.AddCounter(queryPath[0], "TestInstanceName", "float", false) assert.Error(t, err, PDH_INVALID_HANDLE) } else { assert.Error(t, err, PDH_INVALID_ARGUMENT) @@ -70,12 +69,11 @@ func TestSuccessfulQuery(t *testing.T) { t.Fatal(err) } defer q.Close() - counter := CounterConfig{Format: "float", InstanceName: "TestInstanceName"} queryPath, err := q.GetCounterPaths(validQuery) if err != nil { t.Fatal(err) } - err = q.AddCounter(queryPath[0], counter, false) + err = q.AddCounter(queryPath[0], "TestInstanceName", "floar", false) if err != nil { t.Fatal(err) } diff --git a/metricbeat/module/windows/perfmon/pdh_windows.go b/metricbeat/helper/windows/pdh/pdh_windows.go similarity index 99% rename from metricbeat/module/windows/perfmon/pdh_windows.go rename to metricbeat/helper/windows/pdh/pdh_windows.go index b817ddaec16..bccca2c5784 100644 --- a/metricbeat/module/windows/perfmon/pdh_windows.go +++ b/metricbeat/helper/windows/pdh/pdh_windows.go @@ -17,7 +17,7 @@ // +build windows -package perfmon +package pdh import ( "strconv" diff --git a/metricbeat/module/windows/perfmon/pdh_windows_test.go b/metricbeat/helper/windows/pdh/pdh_windows_test.go similarity index 99% rename from metricbeat/module/windows/perfmon/pdh_windows_test.go rename to metricbeat/helper/windows/pdh/pdh_windows_test.go index be08eac32d2..c17a68c31c3 100644 --- a/metricbeat/module/windows/perfmon/pdh_windows_test.go +++ b/metricbeat/helper/windows/pdh/pdh_windows_test.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package perfmon +package pdh import ( "syscall" diff --git a/metricbeat/module/windows/perfmon/zpdh_windows.go b/metricbeat/helper/windows/pdh/zpdh_windows.go similarity index 99% rename from metricbeat/module/windows/perfmon/zpdh_windows.go rename to metricbeat/helper/windows/pdh/zpdh_windows.go index 85cb93dcc75..8d2891b73cb 100644 --- a/metricbeat/module/windows/perfmon/zpdh_windows.go +++ b/metricbeat/helper/windows/pdh/zpdh_windows.go @@ -17,7 +17,7 @@ // Code generated by 'go generate'; DO NOT EDIT. -package perfmon +package pdh import ( "syscall" diff --git a/metricbeat/module/windows/run.go b/metricbeat/helper/windows/run.go similarity index 100% rename from metricbeat/module/windows/run.go rename to metricbeat/helper/windows/run.go diff --git a/metricbeat/mb/testing/fetcher.go b/metricbeat/mb/testing/fetcher.go index be8264b5cbb..5b01e1b8138 100644 --- a/metricbeat/mb/testing/fetcher.go +++ b/metricbeat/mb/testing/fetcher.go @@ -20,6 +20,7 @@ package testing import ( "testing" + "github.com/elastic/beats/libbeat/beat" "github.com/elastic/beats/libbeat/common" "github.com/elastic/beats/metricbeat/mb" ) @@ -32,6 +33,7 @@ type Fetcher interface { FetchEvents() ([]mb.Event, []error) WriteEvents(testing.TB, string) WriteEventsCond(testing.TB, string, func(common.MapStr) bool) + StandardizeEvent(mb.Event, ...mb.EventModifier) beat.Event } // NewFetcher returns a test fetcher from a Metricset configuration @@ -73,6 +75,10 @@ func (f *reportingMetricSetV2Fetcher) WriteEventsCond(t testing.TB, path string, } } +func (f *reportingMetricSetV2Fetcher) StandardizeEvent(event mb.Event, modifiers ...mb.EventModifier) beat.Event { + return StandardizeEvent(f, event, modifiers...) +} + type reportingMetricSetV2FetcherError struct { mb.ReportingMetricSetV2Error } @@ -96,6 +102,10 @@ func (f *reportingMetricSetV2FetcherError) WriteEventsCond(t testing.TB, path st } } +func (f *reportingMetricSetV2FetcherError) StandardizeEvent(event mb.Event, modifiers ...mb.EventModifier) beat.Event { + return StandardizeEvent(f, event, modifiers...) +} + type reportingMetricSetV2FetcherWithContext struct { mb.ReportingMetricSetV2WithContext } @@ -118,3 +128,7 @@ func (f *reportingMetricSetV2FetcherWithContext) WriteEventsCond(t testing.TB, p t.Fatal("writing events", err) } } + +func (f *reportingMetricSetV2FetcherWithContext) StandardizeEvent(event mb.Event, modifiers ...mb.EventModifier) beat.Event { + return StandardizeEvent(f, event, modifiers...) +} diff --git a/metricbeat/metricbeat.reference.yml b/metricbeat/metricbeat.reference.yml index 0ced4f40cd6..072f86f768f 100644 --- a/metricbeat/metricbeat.reference.yml +++ b/metricbeat/metricbeat.reference.yml @@ -73,12 +73,13 @@ metricbeat.modules: #- fsstat # File system summary metrics #- raid # Raid #- socket # Sockets and connection info (linux only) + #- service # systemd service information enabled: true period: 10s processes: ['.*'] # Configure the metric types that are included by these metricsets. - cpu.metrics: ["percentages"] # The other available options are normalized_percentages and ticks. + cpu.metrics: ["percentages","normalized_percentages"] # The other available option is ticks. core.metrics: ["percentages"] # The other available option is ticks. # A list of filesystem types to ignore. The filesystem metricset will not @@ -131,6 +132,9 @@ metricbeat.modules: # Diskio configurations #diskio.include_devices: [] + # Filter systemd services by status or sub-status + #service.state_filter: [] + #------------------------------ Aerospike Module ------------------------------ - module: aerospike metricsets: ["namespace"] @@ -1168,9 +1172,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # List of root certificates for HTTPS server verifications #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] @@ -1260,9 +1264,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -1433,9 +1437,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Certificate for SSL client authentication #ssl.certificate: "/etc/pki/client/cert.pem" @@ -1545,9 +1549,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -1770,7 +1774,7 @@ setup.template.settings: #setup.ilm.pattern: "{now/d}-000001" # Set the lifecycle policy name. The default policy name is -# 'metricbeat-%{[agent.version]}'. +# 'metricbeat'. #setup.ilm.policy_name: "mypolicy" # The path to a JSON file that contains a lifecycle policy configuration. Used @@ -1814,9 +1818,9 @@ setup.kibana: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -1990,9 +1994,9 @@ logging.files: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -2020,6 +2024,14 @@ logging.files: #metrics.period: 10s #state.period: 1m +# The `monitoring.cloud.id` setting overwrites the `monitoring.elasticsearch.hosts` +# setting. You can find the value for this setting in the Elastic Cloud web UI. +#monitoring.cloud.id: + +# The `monitoring.cloud.auth` setting overwrites the `monitoring.elasticsearch.username` +# and `monitoring.elasticsearch.password` settings. The format is `:`. +#monitoring.cloud.auth: + #================================ HTTP Endpoint ====================================== # Each beat can expose internal metrics through a HTTP endpoint. For security # reasons the endpoint is disabled by default. This feature is currently experimental. diff --git a/metricbeat/module/docker/diskio/helper.go b/metricbeat/module/docker/diskio/helper.go index 17895944e28..e75c21b886f 100644 --- a/metricbeat/module/docker/diskio/helper.go +++ b/metricbeat/module/docker/diskio/helper.go @@ -174,5 +174,11 @@ func calculatePerSecond(duration time.Duration, old uint64, new uint64) float64 if value < 0 { value = 0 } - return value / duration.Seconds() + + timeSec := duration.Seconds() + if timeSec == 0 { + return 0 + } + + return value / timeSec } diff --git a/metricbeat/module/kubernetes/fields.go b/metricbeat/module/kubernetes/fields.go index 6feb3a43320..7e772a7534b 100644 --- a/metricbeat/module/kubernetes/fields.go +++ b/metricbeat/module/kubernetes/fields.go @@ -32,5 +32,5 @@ func init() { // AssetKubernetes returns asset data. // This is the base64 encoded gzipped contents of ../metricbeat/module/kubernetes. func AssetKubernetes() string { - return "eJzsXU9z47aSv8+nQM1psuXosLW1hzlsVeK8V881k3le25MctrYUmGxJiEmAAUB79D79KwD8JxIAQRGSPTZ1SGVsq/uH7gbQ3Wg0fkQPsP+IHsp74BQkiHcISSIz+Ijef2p++P4dQimIhJNCEkY/ov95hxBC7R+gHCQnifo2hwywgI9oi98hJEBKQrfiI/q/90Jk7y/Q+52Uxfv/V7/bMS7XCaMbsv2INjgT8A6hDYEsFR81gx8RxTn04KmP3BeKA2dlUf3EAk99ruiG8RyrHyNMUyQklkRIkgjENqhgqUA5pngLKbrfd/isKgpdNF1EuCAC+CPw5jc2UB5gPfn9dH2FDMGOKOvPoUjrTx9aFx6Hv0oQcpVkBKg8+JMa5wPsnxhPe7/zoFWfS00PwTdISqXXmpHwouAgWMkTiIfjxlCGFFlp9wGI8v6UGFzkBzASVsQHgDRZ9CHJSiGBX2imosAJXDTS+cGL6xH4fTxY/7i7u0YDkgPLZGlEUWieA5JDnlQClWvFKL4aKgyaBRqw6GNJ+X7NSxoPxu8gd8CR3EHNA5UCBEr5HvUZ9cE8ENrnNgPJJ0JTtbpW1EdUkheMxl2japJoh2maqVWqIxQvmv7aPROJWtQ1SbRhtWYClolH4IKwiKZREWxQDIfZh6Ald7C5zYRQTxIb4T7zHOSORbRHPTEtRAeDZiKiGTYj7lOt2RacJSCElaPNEG37fZdeUpQrAcng9zXNlJX3WX/dGwzk8vorEpAwmvaRtZxyyBnfq22dpEDl6n7femZDvhmjW8svjV/2Ebm+fIDqZ/VHiFBU86wwjEF8JFyWODsnworlGMBNKlasALpKWDlY/UahHbD+Uub3wNWKqwiiDcmg+QPG3WoUEnMJaQSjuTUGgwShCeglpjLumod1AqhAIJr1N/tqybW3vyrFqgCeAJUkg9V/OEfI7v+ExKYA84v1FDnUc74GgXKScFZNJ9TCcevENgxR5jP148eVlHmZYUkeAdlY+aDNN94amqakd6ia/igQQf4FZmbH1PQU0ArBJLV2IPu0GmNBOsA4UcUdmKfQsCLvwSAKRgU8q3oNhCn6HYI+vYK7KIM1PAQaQ8UVFDupodMf36bqgVl3GpMGWfn4O3k7tto68YGwQJYsS2/I8Zy8iN6CNXfTZZZhCTTZH2PJNm2JmuCFMlGFwPybGMepuyeNQopnQg0mOl0w92XyAPKsW07FGu2IkGzLcY4MCDfYUFdiCoqaptFkqPJO4zm0WGjXETY/DAPzDHpsUYdrMik5V+vYfNld0U1GtjsZYOqMbnlJKaHbqKFKu34metNS30YVI39WGWSSrozco6zkbdK/0qZAWGouVva4TIlcwaNLEVPZa3pI07OP1zDkoKBBGpFnTbLPvN1rqMSEzjvj6Ei3oRfliENHlmtJcnsqN8Wy/4uRhM2tIogGBDvpleBdfCxDef0VlQJvwSII17C7UPR3nfPQBshH9WCQjNsIjxMfY9BlYlmU+2wca0n9GZFv93PZGJ2S+iXjUImeYurcsA7QYsqUWFygRwEHgjVGAekIwwYWS2FVWPekFpVIcAbpepMx7PrDOuSoopwYY1DSxQLhmqb6N9votJBkEmcaO8JZxhIs8X0G6nvewWYkJ/L7G20KG0IhNfCb7Hu7DH5QP3FKBJENKqn+LqT2A7yMbcPzxyOj+sy2yg3fsImLEX7EJMP2JNT8BckVCaOQmTcWTqNwXWvpNENFCS5wQuReub526s2KWv3l65eOseRwyajF7vVLRS/p4UIhaiVwn1TM29vt3juKuIndaRto54lzOJ2DEA5+lyMWKsUoBJDDLuMD0qZhAXR4hhUtdfQ2Fuq+BY4cw53OlX5ZAjFicA73hfuVv3bQT3QtHfpHL967DBnzDAezMgi3j9mVEB+UKaBXNUdubm/9M6QG/MT4A6FbAe402GuQx+9mmEiADJNLgbewwWVmSSROSQ/aEbV5K8UGOfg0uyb+k/Ez4dG8nKia2cOY3ESs83kLEcUNY1JXsoi9kJBPDi7ehrNjl1LX/X7rMZhdQpXn/Xyx2BlijK+W6KKb2ecsy4Cbyw+zMvyXDbHqKkWc/P6zlKCesyr93GWuZy5vVf+Nx+4LziGsivpfjEbke0U3HAvJy0SWHIbEl2JeM5ylmHcp5l2KeQOGsRTz2oEsxbzBGJdi3qWYdynmnV/Ma/Eyp5b3PjH+8FcJpd3jPGbrU6BBOZym5G7+dv7ZEGxq66rN3OdLlHRDKBG7KO7E14ZYCGucpjFs+PdaL4rgiCGnUMhdVJ6a4uj0kZxEma8t324Fs6ZuD8xYCqtEBeyJZPb4+hjDhUeSaE8ipg+sjy1qyj6D3QHO5C5GXXjLvKGK7ImgU9Tk+zkZPI6jqnB21wcHSe5BNmsS4BT4ioh1joV05GTuGcsA9x29sUvru/bWutY1EajH410fja5WfddnPyFhdbeDbusNU/1a56xA7UN6bjS/kTssEeaAtkCBY2l6hdS1wtW6esCBUBXYKuF+6ncuQROSYW4Dc+jaK+1Ls70qLohDwngqjNwb45MkB/OzAnNJkjLD3AgB7bBALNEF6KkFof6mxHlhQTlcTHxpvw3hQq4rVtTRr2N6ce9dDVCNU/NALQ/1s75VdS97nByQYjGCp82FiMFJnMEg4ZsMt4ZfDZ3KEiBtmwOQR6AWcSSs2K8lsyFo9zQseqGeO/XmRXejKYWCa6yw33TjSO53+6I5YvdzzEHiFEscZPYj+jCUEBaCJUSvMk9E7rw68U0k+5ScvsM3ixAH3E/+IN8ECDipOJgEmgFh1C/5kyaYK85+nrq1TlzGmiQiFD3tSLKrltwnLNodx4qmzoOvo3cM+a3qGNIViD/tXpKIRxlfKfmrBKSTw2RDlIPAOkAsyYEmDQrZZp0R+hARzM1nxKHgIBSaqpuMa0Eg9JFlj5CuLRhPtS7UPG1y8a0QuCDxLeen66um30xlPR51xW08pHg/VM2HRhjHXTxoZ/HwMD3dfK0pTxB93An79eqXEd7d8HOO9965UKYjhuUu2XKXzPGJfZfsi7K37/sa2VJbbvssteW9T7za8qWEuAd4KSG2A19KiD0lxBSkspto6zX/9qqN7wYSII86T+ui1WSTObedRwViDsXzzcWnyda8boXccUxFTqR8OTq5s+qkSUMv9frmEyjNvy+l+hMFtFTpt5+BcN5CgX7noNlxEbgP6hw3uFtUL+PudovHdX+78WlK6szgHLNuk1x5gCe6i+/eE8YZjDFBgTMchaZIQmY6mpZKucq1xzt910CBOwd6y2IM2FvQlMXuDYrQvgM1werBHZs5OeyCpd9lCnuJSM1niUjbz/ekkO8uIn0TZ0Yv5JRkAOslNkWZ0mzvTTXYU1tq0wNF9JughHXWi3w+thwF9WC/yBm1tBmKN82O7jX0NtKBB9PFPeTeoeH6tZ8aGrE8Dc4O3WHDKz9WNgJpLsoriegbgiNiKfAW1ic7vTSggk9S1+dA4z5H7bRo+LafE7V37oxoWvMfbG3u9VhakhxdOe/qctJmkdMoVfK27iaduvh+G5I5XAbkGsH1u4/MldohPV93jymXW8b7enhvVAb29JjW0cMz7fzr1zG9PCZ18oiMzNvDI7CDhwfSjO4dIb07wg1jSt8OZ9eO46x6cr8O7yX/kF4dUTp1TO3TEQuR93r/9A4docYZ3J3j2N4c4VoNBzvStWFiT444S0t4N47JvTiO16WlD8fRXTjiKjKs/8bU7huxVBncd2N6143JIrKRCeu3cZTd2JzDseYax9w8Dmyr0WyHe5oEbUpepg/lPRg3vXLW9zSx5rtHtrYyAxG4M4yL/3ZPk2sF50aR7T2jxjbND8YexHOjm2ceTnwBT6u5MTmfV4u5zjihj72v1jvRLLj+45zQbTS1fzGkUYf2pCf0AiHO9F29ICcYwAjKs1iDfzBukxhkDUSyg7TM5rVI7WQOGnpL2mDI45WlDQaXTI9kM9b8tOOZlFmUgd1WVoqwlJAXcki65tmsBhHZqslqo7ukY5Z0zBikJR2zpGMmIlrSMUs6ZknHLOmYJR1jxeDt/mf423r/eSFM6fs3iMX63faO2yThP+H8YenfaIokQ0DTzmDs21Ig7DlpiQloPBOwj2jejLBj8s3EgqWrgoMKUxQC3Sw0nwvjmqWoJYoqoh4EVaAUg29NyjvqRuKVgs7p4N1ajGV8JxkgnufT2UAEbRgDHDNTpi4rfddn/LLf0z+6HdRAPO2T68Tet05ILMt4F6yLHRbuakH7APqD8FUhN8PRjNCHquPrBXrCROr/kcBzQrH/DUXAqfsOuL17biDKFqFmYpfvgcekIlB3LRahEraDNr9HgDF8RjthD7qGdsHM0t/vRkPoQ4PqUneZVEq75FjsPjNW/IyTB7bZXKC/ca5vg12XWXaBmv+tfj9Urfow3mhfrUAfLlleZCAhvWglcYkpZfKmpJoF4xfon//89RPJMkh/qIa/sk6UKXc+RhvL6/Jj110HQ9dVdTxJ7ZfXX3XvL2FYevReO7VngVSxgxTZGR7KyXcvZKRgseCQqKXgI/rv1X/FQN5gCRSoD/s4vLnlmC6pn7UfmVHi6R+KGhNBVeBtCudH+xnUCnx+3K3a6tp9103YhDP6J7uP5dIYalEcmsHpS7hLgy4rHAMa/WPBuQysdDoOY9US3D4zQvi0JFDBMtKj1Fy6SJTTPOMtlTanYEipmEi0L1IPjKTjd4q1KEUBNB1cQve5Rgfcu+mE2oSIilltdFvL1Q2tLWl+TxByGKsWLNkhMUj01xCesLC2zW5WKSzkuraAaDiU0HVD+RoGL6l9gsC3E7FXlEfZp4DTjFA35zGb+6Ui0LDGGwm8mVIaScL0UwxcOYEbTLKOJkL+x/9Pd6iXQpGxfT7zoYrOwtgSjLI2FtjS8yF4ug13j09WpIaLLRxpd7wiIwkOjwWPwlFzQYRu2ERPIgVBuKf90qxY6ZcWY1tfU3FsUX8QBSRzLszFwti2FXHorXPhlZ4PVodXALAitT5jEB2U4TME1L0BG2lxiNkHO2Zixp/ymBXY61bM3WwH+iB5CRdogzMBKiov6QNlT9Q9b0pa7RReI52VmNEoD/j4FsOY0X7n+u3pAuymH3b3sq8/uq4bPI2AmtFZtcbUtJI6XxPsjsyfK4T74rp7PRZ7Nop5VuQVWn8bsM6xy0l0p2+xn8o0u7pRMdK4Qk4KR1/i7zejawQMXBAhgcpHlpV5rO2qJYsM3XrvQhvOcv2XP6plEn707GnwrQBO1FZ7IJxTJQR+M0AVCUeq1jd/wuKZioe1N6DvrGPqIMwxBk4SxlP9ng3raMfhFzCOt7BOMux44z6A+60hgjSRJjUwsCwUEnC5LDTJMMlPZqZJhr8LY73+7dJjqWYw6zkMfiY0hbQWi5tVlUZcV/YzY27ctNn7eqLFnx9KbpqAnTZOEhBinfcL4Sdw+EmTQIqEnccJZ9r1b5cr18Syb6mzZk+kvobE/n7d4MfhiQGF7OraymzHhFyfhqMi7WI7MeyaxrgKj47r9HbCo/UezOps/aY+W78Gqjan1Wp17JF6THTzIs06I+nOOsTE2nCz4b0You3n4iBWzrIiWLXxmb8UnDBZ2IXqzlrGeAdpRp+b3eEL31V2sACObsw/bi3doULzmM+Fyz+H46FS83cqNnavO/ycSmjV4576ybyKE7rf6726BaervDjL+vf80ME50j34VpdYUtyUWbavuY1Ks1NupC+s/VWyg4dy5y0tHZpRFpfTnQbeVFj/V2MdOxPsS2kKAsOB0A3jOaToww7zVG9QAtIffBcI44QdhwN1Hp3L/ivNE1h0R2hmjvrqBfpDDfUPNdY/1GD/cOwfloEfMT5NTovSmB8uioyAQJINA1X/P92BrVoOSBIr41JR802UM4eotxUiT0IlK4UEfpw7fkUlcIozdHXd2H0lBDs3+Ga+MCssrgdVE0O/fLl1z4OGpWOExzB0BBgZw+n6HmeYJm6JBvD7zHCKfq7oNFblYDpnntcDG9BowkK65SoYP34sV4aCC33NQMVtTpsYM0LD4R82Egd7txiU7HsK9g/K9UOUpjmYS2mDVWWwAdq3npHXA2p1NU+4W75wxBoosYRNmcWLSGqK0UISn9DGUlpDj+tu1xFh834/+gDKszAb+G01gr7beoYY6UB4jfN3VJh0Yse606uk9qsPnFWXENEzxEuDag8fwBpcGzmcWs+dGKXjdb0sdTdK7oB9GWqulRsArFn09CM0sdY786JNp0t3lEXPco8JTdl6LS9SNJXH7orb5Y32/scNyEf1YJCv7o325Xl2C7nl+Ymui/TKW8YvL5EffpaXyMPwjHfQj1oFdFj6M8shmZOzGUqlU+pj5bY8DV19Auff8jT0VAEtT0O3nzf5NPTXwAehz/D+8t8dry73oZzjbWrj5FVg/h0AAP//kXovWQ==" + return "eJzsXU9z27iSv+dToHLKbHl02NraQw5bNeN5r54rmTyv7cwctrY0MNmSMCYBDgDa0fv0rwD+g0gABEVIdmzykIolsfuH7gbQ3QAaP6IH2H9ED+U9cAoSxDuEJJEZfETvP7Ufvn+HUAoi4aSQhNGP6H/eIYRQ9wOUg+QkUW9zyAAL+Ii2+B1CAqQkdCs+ov97L0T2/gK930lZvP9/9d2OcblOGN2Q7Ue0wZmAdwhtCGSp+KgZ/IgozqEHTz1yXygOnJVF/YkFnnqu6IbxHKuPEaYpEhJLIiRJBGIbVLBUoBxTvIUU3e8NPquagonGRIQLIoA/Am+/sYHyAOvJ76frK1QRNETZPIcibZ4+NBMeh79KEHKVZASoPPhJg/MB9k+Mp73vPGjVc6npIfgGSan02jASXhQcBCt5AvFw3FSUIUVW2n0Aorw/JQYX+QGMhBXxASBNFn1IslJI4BeaqShwAhetdH7w4noEfh8P1j/u7q7RgOTAMlkaURSa54DkkCeVQOVaMYqvhhqDZoEGLPpYUr5f85LGg/E7yB1wJHfQ8EClAIFSvkd9Rn0wD4T2uc1A8onQVI2uNfURleQFo3HHqIYk2mGaZmqUMoTiRdMfu2ciUYO6Jok2rNFMwDDxCFwQFtE0aoItimEz+xC05A4mt5kQmk5iI9xnnoPcsYj2qDumheig0UxENMO2xX2qDduCswSEsHK0GaJtvjfpJUW5EpAMvm9opqy8z/rj3qAhl9dfkYCE0bSPrOOUQ874Xk3rJAUqV/f7zjMb8s0Y3Vq+rPyyj8j18gGqn9WPEKGo4VljGIP4SLgscXZOhDXLMYCbVKxYAXSVsHIw+o1CO2D9pczvgasRVxFEG5JB+wPG3WoUEnMJaQSjua0MBglCE9BDTG3cDQ9rB1CBQDTrb+fVkmtvf1WKVQE8ASpJBqv/cLaQ3f8JiU0B1RfrKXJo+nwDAuUk4azuTqiD49aJrRmizGfqx48rKfMyw5I8ArKx8kGbb7wNNE1Jz1AN/VEggvwLqp4dU9NTQCsEk9RqQPZpNcaAdIBxoooNmKfQsCLvwSAKRgU8q3orCFP0OwR9egWbKIM1PAQaQ8U1FDupodMf36aahllnmioNsvLxd/J2TLVN4gNhgSxZll6T4zl5Eb0Fa+7GZJZhCTTZH2PJNm2JhuCFMlGFoPqbVI6TOSeNQopnQi0mOl0w92XyAPKsU07NGu2IkGzLcY4qEG6woa7EFBQNzUqToco7jefQYaGmI1x9GAbmGfTYoQ7XZFJyrsax+bK7opuMbHcywNQZ3fKSUkK3UUOVbvxM9KSl3kY1I39WGWSSriq5RxnJu6R/rU2BsNRcrOxxmRK5gkeXIqay1/SQpmdvb8WQg4IGaUSeDck+826uoRITOm+Nw5BuSy/KEoeOLNeS5PZUbopl/4uRhM2tIogGBI30SvAsPpahvP6KSoG3YBGEq9kmFP2usx/aAPmoHjSScRvhceJjDEwmlkG5z8YxljTPiHzN57I1OiX1S8ahFj3F1DlhHaDFlCmxuECPAg4EWxkFpCMMW1gshVVhnZM6VCLBGaTrTcaw64dNyFFHOTHaoKSLBcINTfU32+i0kGQSZxo7wlnGEizxfQbqPW9jM5IT+f21NoUNoZBW8NvsezcMflCfOCWCyAaVVL8LqX0BL2Pb8PzxSKs+s61ywzds4mCEHzHJsD0JNX9AckXCKKTnjYXTKFzXWjptU1GCC5wQuVeur516O6LWv3z90qksOVwyarB7/VLRQ3q4UIgaCdwrFfPmdrv3jiJOYnfaBrp+4myOsRDCwe9yxEKlGIUActhlfEDaNCyADtewoqWO3sZA3bfAkWW407nSL0sglRiczX3hfuWvBvqJrqVD/+jFe5chbZ7hYNYG4fYxTQnxwTYF9Kr6yM3trb+HNICfGH8gdCvAnQZ7DfL4vWomEiDD5FLgLWxwmVkSiVPSg3ZEXd5KsUEOPu2sif9k/Ex4NC8nqrb3MCY3Eff5vIWI4oYxqXeyiL2QkE8OLt6Gs2OXkul+v/UYzC6h2vN+vljsDDHGV0t0YWb2Ocsy4NXhh1kZ/suWWH2UIk5+/1m2oJ5zV/q5t7meeXur+jceuy84h7Bd1P9iNCLfK7rhWEheJrLkMCS+bOatmrNs5l028y6beQOasWzmtQNZNvMGY1w28y6beZfNvPM381q8zKnbe58Yf/irhNLucR4z9SnQoBzOasvd/On8c0Ww3VtXT+Y+X6KkG0KJ2EVxJ762xEJY4zSNYcO/N3pRBEcMOYVC7qLy1BRHu4/kJEp/7fiaO5g1dXtgxlJYJSpgTySzx9fHGC48kkR7EjF9YL1s0VD2GewOcCZ3MfaFd8xbqsieCDrFnnw/pwqPY6kqnN31wUKSu5HtmAQ4Bb4iYp1jIR05mXvGMsB9R2/s0PquO7WudU0E6vF410ejd6u+67OfkLC624FZeqPa/drkrEDNQ7pvtN/IHZYIc0BboMCxrGqFNHuF63H1gAOhKrBVwv3Ur1yCJiTD3Abm0LVX2pfV9Kq4IA4J46mo5N4anyQ5VJ8VmEuSlBnmlRDQDgvEEr0BPbUg1G9KnBcWlMPBxJf22xAu5LpmRR31OqZv7r1rAKp2ah6o46E+61uVedjj5IAUixE8XS5EDFbiKgwSvslwa/i1olNbAqRdcQDyCNQijoQV+7VkNgTdnIZFL9Rzp9686G40pVBwrRX2i24cyf1uX7RL7H6OOUicYomDzH5EHxUlhIVgCdGjzBORO69OfB3J3iWnz/DtIMQB95M/yNcBAlYqDjqBZkAY9Uv+pAnmmrOfpy6tE5exJokIRU87kuzqIfcJi27GsaJp8uDr6BVDfqsrhpgC8afdSxJxKeMrJX+VgHRymGyIchCYAcSSHGjToJBt1hmhDxHB3HxGHAoOQqGpq8m4BgRCH1n2COnagvFU40LD0yYX3wiBCxLfcn66vmrrzdTW41FX3MJDivdDXXxohHHcwYMag4eH6en6a0N5gujjdtivV7+M8DbDzzneu3GgTEcMy1my5SyZ44l9luyLsrfv+xjZsrfc9ix7y3tPvL3lyxbiHuBlC7Ed+LKF2LOFmIJUdhNtvObfXrXx3UAC5FHnaV202mwy57b1qEDMoXi+ufi02ZrXrZA7jqnIiZQvRyd3Vp20aehlv371BErz78tW/YkCWnbpd89AOG9hg76x0Ow4CNwHdY4T3B2ql3F2u8PjOr/d+jQldWZwjhm3Sa48wBOdxXfPCeMMxpigwB6OQlMkIT0dTUulXOXa450+a6DAmQO9ZTEGzC1oymD3BkVon4HaYPXgjM2cHHbB0u8yhb1EpNWzRKTd8z0p5LuLSN/EmtELWSUZwHqJRVGmFNt7UwX21JTa1kAR/SIoYZX1Iq+PLUtBPdgvskctZYbidbOjaw29jXTgQXdxN7m3aLh+7auGlVieBmuH7rDhlS8rVwJpD8oriegTgiNiKfAW1idbvaxABa+krs+Bxr2OapRo+LafE7UbZ0Y0rfkXtrbneiwlSY7eOe+qctJlkdMou+Rt1U2MffH9MiRzuAzItYLrVx+ZK7VDer7qHlMOt4zX9fCeqAys6TGtooen2/nHr2NqeUyq5BEZmbeGR2AFDw+kGdU7Qmp3hBvGlLodzqodx1n15Hod3kP+IbU6olTqmFqnIxYi7/H+6RU6Qo0zuDrHsbU5wrUaDnakasPEmhxxhpbwahyTa3Ecr0tLHY6jq3DEVWRY/Y2p1TdiqTK47sb0qhuTRWQjE1Zv4yi7sTmHY8U1jjl5HFhWo50O9zQJmpS8TB/Ke6jc9NpZ39PEmu8emdrKDETgzDAu/ts9Ta4VnBtFtneNGtu0H4xdiOdGN888nPgCrlZzY3JerxZznHFCH7tfrbeiWXD945zQbTS1f6lII4P2pCv0AiHO9F29ICcYwAjKs1iDvzFukxhkDUSyg7TM5pVINTIHLb0lbTDk8crSBoNDpkeyGSt+angmZRalYbe1lSIsJeSFHJJueLajQUS2qrPa6C7pmCUdMwZpSccs6ZiJiJZ0zJKOWdIxSzpmScdYMXir/1X8bbX/vBCm1P0bxGL9anvHTZLwn3D+sPRvNEWSIaCp0Rj7tBQIe05aYgIaTwfsI5rXI+yYfD2xYOmq4KDCFIVAFwvN58K4ZinqiKKaqAdBHSjF4NuQ8ra6lXitoHM6eLcWYxmfSQaI5/l0NhBBE8YAx8yUqctK3/UZv+z79I8uBzUQT3flOrHXrRMSyzLeAetih4V7t6C9Af1G+HYht83RjNCHuuLrBXrCROr/SOA5odh/hyLg1H0G3F49NxBlh1Azscv3wGNSEah7LxahEraDMr9HgKn4jFbCHlQNNcHM0t/vlYbQhxbVpa4yqZR2ybHYfWas+BknD2yzuUB/41yfBrsus+wCtf+tvx+qVj2Mt9pXI9CHS5YXGUhILzpJXGJKmbwpqWbB+AX65z9//USyDNIf6uavrB1lypmP0cLyevux66xDRde163iS2i+vv+raX6Ji6dF749SeBVLNDlJkZ3goJ9+5kJENiwWHRA0FH9F/r/4rBvIWS6BAfdjH4c3djumS+lnrkVVKPP1FUWMiqDd4VxvnR+sZNAp8ftyd2pq9+66TsAln9E92H8ulqahFcWgGqy/hLg26rHEMaPSXBecysNIxHMa6JLi9Z4Tw6UiggmWkR6k9dJEop3nGXSpdTqEipWIi0d1IPTASw+8Ua1GKAmg6OITuc40OuJvphMaEiIpZbXQ7y9UFrS1pfk8QchirFizZITFI9DcQnrCwls1uRyks5LqxgGg4lNB1QfkGBi+pvYPAtxOxV5RH2aeA04xQN+cxm/ulJtCyxhsJvO1SGknC9FUMXDmBG0wyQxMh//H/6Q71Uigyts9nXlRhDIwdwShjY4EtNR+Cu9tw9vhkRVpxsYUj3YxXZCTB4bHgUTgaLojQDZvoSaQgCPeUX5oVK/3SYez219QcO9QfRAHJnANzsTB2ZUUcejMOvNLzwTJ4BQArUus1BtFBVXyGgMwTsJEGh5h1sGMmZvwpj1mBvS7FbGY70AfJS7hAG5wJUFF5SR8oe6LuflPSeqbwGumsxIxGecDHNxjGjPaN47enC7DbetjmYV9/dN0UeBoBNaOyaoOpLSV1viLYhsyfK4T74jp7PRZ7top5VuQ1Wn8ZMGPZ5SS606fYT2Wapm5UjDSukJPC0Yf4+8XoWgEDF0RIoPKRZWUea7rqyKKKbjN3oQ1nuf7lj2qYhB89cxp8K4ATNdUeCOdUCYHfKqCKhCNV6+s/YfFMzcNaG9C31jG1EdUyBk4SxlN9nw0ztOPwCxjHW1gnGXbccR/A/bYigjSRNjUwsCwUEnC5LDTJMMlPZqZJhr8LY73+7dJjqVVj1nMY/ExoCmkjFjerOo24ru1nRt+46bL3TUeL3z+U3DQBO22cJCDEOu9vhJ/A4SdNAikSdh4n7GnXv12uXB3LPqXO6j2R6hoS+/11g4/DEwMK2dW1ldmOCbk+DUdF2sV2Ytg1jXEdHh1X6e2ES+s9mPXa+k2ztn4NVE1Oq9Xq2CX1mOjmRZpNRtKddYiJteVmw3sxRNvPxUGsnGVNsC7jM38oOGGy0ITqzlrGuAdpRp2b3eEN33V2sACObqo/bi3VoULzmM+Fy9+H46FS/XcqNnavK/ycSmj15Z76yryaE7rf67m6A6d3eXGW9c/5oYN1pHvwjS6xpLgps2zfcBuVprHdSB9Y+6tkBxflzhtaDJpRBpfTrQbe1Fj/V2MdWxPsS2kKgooDoRvGc0jRhx3mqZ6gBKQ/+A4Qxgk7DhvqXDqX/VuaJ7AwW1j1HPXqBfpDNfUP1dY/VGP/cMwfloYf0T5NTouyMj9cFBkBgSQbBqr+P92BrRoOSBIr41JT83WUM4eotzUiT0IlK4UEfpw7fkUlcIozdHXd2n0tBDs3+Fa9MCssbhrVEEO/fLl194OWpaOFxzB0BBgZw+n6HmeYJm6JBvD7zHCKfq7ptFblYDqnnzcNG9Bow0K65SoYP74tVxUFF/qGgYrbnDYxZoQVh3/YSPTmHfuIP1K0v5FSe3O65YUjhh6JJWzKLF4g0FCMFgn4hDaWSRo6Onc7Q4TttfnoA6gJvZo3b+sW9L3FM4QmB8Jrfa6jopMT+7NGiZDGnT3wEV1CRM8Qpgw2WfgANuA6h/3UejZCA8PZeVnqbpVsgH0Zam6UGwCsHfT03S+xxrvqIhmjOHaUQc9yfAhNmfEsF0G0G37dG12Xq9H7jxuQj+pBI1/d1ejLregWcsutD6aL9MortS8XgB8+ywXgYXjGC9dH3XxzuONmlkMyJ1UylIqxw8bKbbmRuX4C+99yI/NUAS03MnfPm7yR+WvgPcxnuPb4747LjvtQznEldOXk1WD+HQAA///hGQsL" } diff --git a/metricbeat/module/kubernetes/state_service/_meta/fields.yml b/metricbeat/module/kubernetes/state_service/_meta/fields.yml index 405c846acdd..4a32c52dc77 100644 --- a/metricbeat/module/kubernetes/state_service/_meta/fields.yml +++ b/metricbeat/module/kubernetes/state_service/_meta/fields.yml @@ -28,10 +28,6 @@ - name: ingress_hostname type: ip description: Ingress Hostname - - name: labels.* - type: object - object_type: keyword - description: Labels for service - name: created type: date description: Service creation date diff --git a/metricbeat/module/prometheus/_meta/fields.yml b/metricbeat/module/prometheus/_meta/fields.yml index c6d1f9a1746..ceea6b49dd2 100644 --- a/metricbeat/module/prometheus/_meta/fields.yml +++ b/metricbeat/module/prometheus/_meta/fields.yml @@ -6,15 +6,18 @@ release: ga settings: ["ssl", "http"] fields: - # Order is important here, labels will match first, the rest are double - - name: prometheus.labels.* - type: object - object_type: keyword - description: > - Prometheus metric labels - - name: prometheus.metrics.* - type: object - object_type: double - object_type_mapping_type: "*" - description: > - Prometheus metric + - name: prometheus + type: group + fields: + # Order is important here, labels will match first, the rest are double + - name: labels.* + type: object + object_type: keyword + description: > + Prometheus metric labels + - name: metrics.* + type: object + object_type: double + object_type_mapping_type: "*" + description: > + Prometheus metric diff --git a/metricbeat/module/prometheus/fields.go b/metricbeat/module/prometheus/fields.go index 23d94ffe4c5..5123688cad5 100644 --- a/metricbeat/module/prometheus/fields.go +++ b/metricbeat/module/prometheus/fields.go @@ -32,5 +32,5 @@ func init() { // AssetPrometheus returns asset data. // This is the base64 encoded gzipped contents of ../metricbeat/module/prometheus. func AssetPrometheus() string { - return "eJyUkc1qwzAQhO9+ikG9hSQPoENfoYUeSwmKtba30R+7G0LeviQ2aQIttLppv9FoNNrgQGePJjWTTXTUDjC2RB7u9TZ0HRBJe+FmXIvHcwcAbxZMob2ERhGD1IyA71OgElvlYtsO0KmK7fpaBh49hpCUOkAoUVDyGMNFQ2ZcRvV4d6rJreEms+Y+OmBgSlH99d4nvEgkASs4tyoWimEioTVS2FNSnDgl5GD9hIFFbQ2bCEJqCEKI9bhPdPXaoIRM9w1sZ4/t6soBOzfyqPtP6m0ZzZvdTA50PlWJC/qhpsu6ayWTCfdL0t8yzKK/h7h70QPZ5dAal3GRuZX7Z84b2Tx81lcAAAD//3hXtDU=" + return "eJyckU1Ow0AMhfc5xdOwq9oeIAuuABJLhKppxklM50+2q6q3RyFtCYUNePmen/2NZ4MDnVtUKYlspKM2gLFFauGeb6JrgEDaCVfjkls8NgDwYt4U2omvFNBLSfD4SoFyqIWzbRtAxyK260rueWjR+6jUAEKRvFKLwU89ZMZ50BavTjW6NdxoVt1bA/RMMWj7uXeD7BPdUU9l5zrNknKsF2UZm+oBTxJIwApOtYj5bBhJaI3o9xQVJ44RyVs3omdRW8NGgpAavBBCOe4j3eZdUebwdnUzrjBl/06dLeRZ2M3ugc6nImFh/3Lmay0um8iEu8vWHzCz+3eau7d9c3fJ18p5uLS6lfsn9IJ2+fsfAQAA//+kwcDt" } diff --git a/metricbeat/module/system/_meta/config.reference.yml b/metricbeat/module/system/_meta/config.reference.yml index c22fc6ac279..a6023d23ddc 100644 --- a/metricbeat/module/system/_meta/config.reference.yml +++ b/metricbeat/module/system/_meta/config.reference.yml @@ -14,12 +14,13 @@ #- fsstat # File system summary metrics #- raid # Raid #- socket # Sockets and connection info (linux only) + #- service # systemd service information enabled: true period: 10s processes: ['.*'] # Configure the metric types that are included by these metricsets. - cpu.metrics: ["percentages"] # The other available options are normalized_percentages and ticks. + cpu.metrics: ["percentages","normalized_percentages"] # The other available option is ticks. core.metrics: ["percentages"] # The other available option is ticks. # A list of filesystem types to ignore. The filesystem metricset will not @@ -71,3 +72,6 @@ # Diskio configurations #diskio.include_devices: [] + + # Filter systemd services by status or sub-status + #service.state_filter: [] diff --git a/metricbeat/module/system/cpu/config.go b/metricbeat/module/system/cpu/config.go index 169d59ca1f9..291ee7963ef 100644 --- a/metricbeat/module/system/cpu/config.go +++ b/metricbeat/module/system/cpu/config.go @@ -62,5 +62,5 @@ func (c Config) Validate() error { } var defaultConfig = Config{ - Metrics: []string{percentages}, + Metrics: []string{percentages, normalizedPercentages}, } diff --git a/metricbeat/module/windows/perfmon/doc.go b/metricbeat/module/windows/perfmon/doc.go index 66e0df7b5da..bab02b5f128 100644 --- a/metricbeat/module/windows/perfmon/doc.go +++ b/metricbeat/module/windows/perfmon/doc.go @@ -15,12 +15,4 @@ // specific language governing permissions and limitations // under the License. -// Package perfmon implements a Metricbeat metricset for reading Windows -// performance counters. package perfmon - -//go:generate go run mkpdh_defs.go -//go:generate go run ../run.go -cmd "go tool cgo -godefs defs_pdh_windows.go" -goarch amd64 -output defs_pdh_windows_amd64.go -//go:generate go run ../run.go -cmd "go tool cgo -godefs defs_pdh_windows.go" -goarch 386 -output defs_pdh_windows_386.go -//go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zpdh_windows.go pdh_windows.go -//go:generate gofmt -w defs_pdh_windows_amd64.go defs_pdh_windows_386.go zpdh_windows.go diff --git a/metricbeat/module/windows/perfmon/perfmon.go b/metricbeat/module/windows/perfmon/perfmon.go index 05210599854..a3d048ebcf7 100644 --- a/metricbeat/module/windows/perfmon/perfmon.go +++ b/metricbeat/module/windows/perfmon/perfmon.go @@ -90,7 +90,7 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) { // Fetch fetches events and reports them upstream func (m *MetricSet) Fetch(report mb.ReporterV2) error { // if the ignore_non_existent_counters flag is set and no valid counter paths are found the Read func will still execute, a check is done before - if len(m.reader.query.counters) == 0 { + if len(m.reader.query.Counters) == 0 { return errors.New("no counters to read") } diff --git a/metricbeat/module/windows/perfmon/pdh_integration_windows_test.go b/metricbeat/module/windows/perfmon/perfmon_test.go similarity index 94% rename from metricbeat/module/windows/perfmon/pdh_integration_windows_test.go rename to metricbeat/module/windows/perfmon/perfmon_test.go index 1fe12ab20d1..77599ce82c4 100644 --- a/metricbeat/module/windows/perfmon/pdh_integration_windows_test.go +++ b/metricbeat/module/windows/perfmon/perfmon_test.go @@ -24,6 +24,8 @@ import ( "testing" "time" + "github.com/elastic/beats/metricbeat/helper/windows/pdh" + "github.com/elastic/beats/libbeat/common" "github.com/pkg/errors" @@ -106,7 +108,7 @@ func TestCounterWithNoInstanceName(t *testing.T) { } func TestQuery(t *testing.T) { - var q Query + var q pdh.Query err := q.Open() if err != nil { t.Fatal(err) @@ -117,7 +119,7 @@ func TestQuery(t *testing.T) { if err != nil { t.Fatal(err) } - err = q.AddCounter(path[0], counter, false) + err = q.AddCounter(path[0], counter.InstanceName, counter.Format, false) if err != nil { t.Fatal(err) } @@ -177,7 +179,7 @@ func TestNonExistingCounter(t *testing.T) { config.CounterConfig[0].Format = "float" handle, err := NewReader(config) if assert.Error(t, err) { - assert.EqualValues(t, PDH_CSTATUS_NO_COUNTER, errors.Cause(err)) + assert.EqualValues(t, pdh.PDH_CSTATUS_NO_COUNTER, errors.Cause(err)) } if handle != nil { @@ -200,7 +202,7 @@ func TestIgnoreNonExistentCounter(t *testing.T) { values, err := handle.Read() if assert.Error(t, err) { - assert.EqualValues(t, PDH_NO_DATA, errors.Cause(err)) + assert.EqualValues(t, pdh.PDH_NO_DATA, errors.Cause(err)) } if handle != nil { @@ -221,7 +223,7 @@ func TestNonExistingObject(t *testing.T) { config.CounterConfig[0].Format = "float" handle, err := NewReader(config) if assert.Error(t, err) { - assert.EqualValues(t, PDH_CSTATUS_NO_OBJECT, errors.Cause(err)) + assert.EqualValues(t, pdh.PDH_CSTATUS_NO_OBJECT, errors.Cause(err)) } if handle != nil { @@ -231,7 +233,7 @@ func TestNonExistingObject(t *testing.T) { } func TestLongOutputFormat(t *testing.T) { - var query Query + var query pdh.Query err := query.Open() if err != nil { t.Fatal(err) @@ -243,8 +245,8 @@ func TestLongOutputFormat(t *testing.T) { t.Fatal(err) } assert.NotZero(t, len(path)) - err = query.AddCounter(path[0], counter, false) - if err != nil && err != PDH_NO_MORE_DATA { + err = query.AddCounter(path[0], counter.InstanceName, counter.Format, false) + if err != nil && err != pdh.PDH_NO_MORE_DATA { t.Fatal(err) } @@ -271,7 +273,7 @@ func TestLongOutputFormat(t *testing.T) { } func TestFloatOutputFormat(t *testing.T) { - var query Query + var query pdh.Query err := query.Open() if err != nil { t.Fatal(err) @@ -283,8 +285,8 @@ func TestFloatOutputFormat(t *testing.T) { t.Fatal(err) } assert.NotZero(t, len(path)) - err = query.AddCounter(path[0], counter, false) - if err != nil && err != PDH_NO_MORE_DATA { + err = query.AddCounter(path[0], counter.InstanceName, counter.Format, false) + if err != nil && err != pdh.PDH_NO_MORE_DATA { t.Fatal(err) } diff --git a/metricbeat/module/windows/perfmon/reader.go b/metricbeat/module/windows/perfmon/reader.go index b7837862ffc..51eef6b7e95 100644 --- a/metricbeat/module/windows/perfmon/reader.go +++ b/metricbeat/module/windows/perfmon/reader.go @@ -24,6 +24,8 @@ import ( "strconv" "strings" + "github.com/elastic/beats/metricbeat/helper/windows/pdh" + "github.com/pkg/errors" "github.com/elastic/beats/libbeat/common" @@ -37,7 +39,7 @@ var ( // Reader will contain the config options type Reader struct { - query Query // PDH Query + query pdh.Query // PDH Query instanceLabel map[string]string // Mapping of counter path to key used for the label (e.g. processor.name) measurement map[string]string // Mapping of counter path to key used for the value (e.g. processor.cpu_time). executed bool // Indicates if the query has been executed. @@ -47,7 +49,7 @@ type Reader struct { // NewReader creates a new instance of Reader. func NewReader(config Config) (*Reader, error) { - var query Query + var query pdh.Query if err := query.Open(); err != nil { return nil, err } @@ -63,8 +65,8 @@ func NewReader(config Config) (*Reader, error) { if err != nil { if config.IgnoreNECounters { switch err { - case PDH_CSTATUS_NO_COUNTER, PDH_CSTATUS_NO_COUNTERNAME, - PDH_CSTATUS_NO_INSTANCE, PDH_CSTATUS_NO_OBJECT: + case pdh.PDH_CSTATUS_NO_COUNTER, pdh.PDH_CSTATUS_NO_COUNTERNAME, + pdh.PDH_CSTATUS_NO_INSTANCE, pdh.PDH_CSTATUS_NO_OBJECT: r.log.Infow("Ignoring non existent counter", "error", err, logp.Namespace("perfmon"), "query", counter.Query) continue @@ -85,7 +87,7 @@ func NewReader(config Config) (*Reader, error) { return nil, errors.Errorf(`failed to expand counter (query="%v")`, counter.Query) } for _, v := range childQueries { - if err := query.AddCounter(v, counter, len(childQueries) > 1); err != nil { + if err := query.AddCounter(v, counter.InstanceName, counter.Format, len(childQueries) > 1); err != nil { return nil, errors.Wrapf(err, `failed to add counter (query="%v")`, counter.Query) } r.instanceLabel[v] = counter.InstanceLabel @@ -104,8 +106,8 @@ func (r *Reader) RefreshCounterPaths() error { if err != nil { if r.config.IgnoreNECounters { switch err { - case PDH_CSTATUS_NO_COUNTER, PDH_CSTATUS_NO_COUNTERNAME, - PDH_CSTATUS_NO_INSTANCE, PDH_CSTATUS_NO_OBJECT: + case pdh.PDH_CSTATUS_NO_COUNTER, pdh.PDH_CSTATUS_NO_COUNTERNAME, + pdh.PDH_CSTATUS_NO_INSTANCE, pdh.PDH_CSTATUS_NO_OBJECT: r.log.Infow("Ignoring non existent counter", "error", err, logp.Namespace("perfmon"), "query", counter.Query) continue @@ -118,7 +120,7 @@ func (r *Reader) RefreshCounterPaths() error { // there are cases when the ExpandWildCardPath will retrieve a successful status but not an expanded query so we need to check for the size of the list if err == nil && len(childQueries) >= 1 && !strings.Contains(childQueries[0], "*") { for _, v := range childQueries { - if err := r.query.AddCounter(v, counter, len(childQueries) > 1); err != nil { + if err := r.query.AddCounter(v, counter.InstanceName, counter.Format, len(childQueries) > 1); err != nil { return errors.Wrapf(err, "failed to add counter (query='%v')", counter.Query) } r.instanceLabel[v] = counter.InstanceLabel diff --git a/metricbeat/module/windows/perfmon/reader_test.go b/metricbeat/module/windows/perfmon/reader_test.go index 8b4a921b3c3..dd5a58aa522 100644 --- a/metricbeat/module/windows/perfmon/reader_test.go +++ b/metricbeat/module/windows/perfmon/reader_test.go @@ -25,6 +25,8 @@ import ( "github.com/stretchr/testify/assert" ) +var validQuery = `\Processor Information(_Total)\% Processor Time` + // TestNewReaderWhenQueryPathNotProvided will check for invalid/no query. func TestNewReaderWhenQueryPathNotProvided(t *testing.T) { counter := CounterConfig{Format: "float", InstanceName: "TestInstanceName"} @@ -51,9 +53,9 @@ func TestNewReaderWithValidQueryPath(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, reader) assert.NotNil(t, reader.query) - assert.NotNil(t, reader.query.handle) - assert.NotNil(t, reader.query.counters) - assert.NotZero(t, len(reader.query.counters)) + assert.NotNil(t, reader.query.Handle) + assert.NotNil(t, reader.query.Counters) + assert.NotZero(t, len(reader.query.Counters)) defer reader.Close() } diff --git a/metricbeat/module/windows/service/doc.go b/metricbeat/module/windows/service/doc.go index 608c063433b..1bcbc98e250 100644 --- a/metricbeat/module/windows/service/doc.go +++ b/metricbeat/module/windows/service/doc.go @@ -18,7 +18,7 @@ // Package service implements a Metricbeat metricset for reading Windows Services package service -//go:generate go run ../run.go -cmd "go tool cgo -godefs defs_service_windows.go" -goarch amd64 -output defs_service_windows_amd64.go -//go:generate go run ../run.go -cmd "go tool cgo -godefs defs_service_windows.go" -goarch 386 -output defs_service_windows_386.go +//go:generate go run ../../../helper/windows/run.go -cmd "go tool cgo -godefs defs_service_windows.go" -goarch amd64 -output defs_service_windows_amd64.go +//go:generate go run ../../../helper/windows/run.go -cmd "go tool cgo -godefs defs_service_windows.go" -goarch 386 -output defs_service_windows_386.go //go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zservice_windows.go service_windows.go //go:generate gofmt -w defs_service_windows_amd64.go defs_service_windows_386.go diff --git a/metricbeat/tests/system/test_base.py b/metricbeat/tests/system/test_base.py index 59fb16c7c86..5e52872bb7b 100644 --- a/metricbeat/tests/system/test_base.py +++ b/metricbeat/tests/system/test_base.py @@ -71,7 +71,7 @@ def test_dashboards(self): ) exit_code = self.run_beat(extra_args=["setup", "--dashboards"]) - assert exit_code == 0 + assert exit_code == 0, 'Error output: ' + self.get_log() assert self.log_contains("Kibana dashboards successfully loaded.") @unittest.skipUnless(INTEGRATION_TESTS, "integration test") diff --git a/packetbeat/packetbeat.reference.yml b/packetbeat/packetbeat.reference.yml index 86ceb94d6c4..ea639408de4 100644 --- a/packetbeat/packetbeat.reference.yml +++ b/packetbeat/packetbeat.reference.yml @@ -905,9 +905,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # List of root certificates for HTTPS server verifications #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] @@ -997,9 +997,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -1170,9 +1170,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Certificate for SSL client authentication #ssl.certificate: "/etc/pki/client/cert.pem" @@ -1282,9 +1282,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -1507,7 +1507,7 @@ setup.template.settings: #setup.ilm.pattern: "{now/d}-000001" # Set the lifecycle policy name. The default policy name is -# 'packetbeat-%{[agent.version]}'. +# 'packetbeat'. #setup.ilm.policy_name: "mypolicy" # The path to a JSON file that contains a lifecycle policy configuration. Used @@ -1551,9 +1551,9 @@ setup.kibana: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -1727,9 +1727,9 @@ logging.files: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -1757,6 +1757,14 @@ logging.files: #metrics.period: 10s #state.period: 1m +# The `monitoring.cloud.id` setting overwrites the `monitoring.elasticsearch.hosts` +# setting. You can find the value for this setting in the Elastic Cloud web UI. +#monitoring.cloud.id: + +# The `monitoring.cloud.auth` setting overwrites the `monitoring.elasticsearch.username` +# and `monitoring.elasticsearch.password` settings. The format is `:`. +#monitoring.cloud.auth: + #================================ HTTP Endpoint ====================================== # Each beat can expose internal metrics through a HTTP endpoint. For security # reasons the endpoint is disabled by default. This feature is currently experimental. diff --git a/testing/environments/snapshot.yml b/testing/environments/snapshot.yml index 3ee259b0400..16c20266a6e 100644 --- a/testing/environments/snapshot.yml +++ b/testing/environments/snapshot.yml @@ -17,7 +17,7 @@ services: - "indices.id_field_data.enabled=true" logstash: - image: docker.elastic.co/logstash/logstash:8.0.0-SNAPSHOT + image: docker.elastic.co/logstash/logstash@sha256:e01cf165142edf8d67485115b938c94deeda66153e9516aa2ce69ee417c5fc33 healthcheck: test: ["CMD", "curl", "-f", "http://localhost:9600/_node/stats"] retries: 600 diff --git a/vendor/github.com/godror/godror/CHANGELOG.md b/vendor/github.com/godror/godror/CHANGELOG.md new file mode 100644 index 00000000000..72e335fffd1 --- /dev/null +++ b/vendor/github.com/godror/godror/CHANGELOG.md @@ -0,0 +1,18 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [0.10.0] +### Added +- onInit parameter in the connection url (and OnInit in ConnectionParams) +- export Drv to be able to register new driver wrapping *godror.Drv. +- ContextWithUserPassw requires a connClass argument, too. + +## [0.9.2] +### Changed +- Make Data embed dpiData, not *dpiData + diff --git a/vendor/gopkg.in/goracle.v2/LICENSE.md b/vendor/github.com/godror/godror/LICENSE.md similarity index 95% rename from vendor/gopkg.in/goracle.v2/LICENSE.md rename to vendor/github.com/godror/godror/LICENSE.md index f634025b67c..7ca5c6c439f 100644 --- a/vendor/gopkg.in/goracle.v2/LICENSE.md +++ b/vendor/github.com/godror/godror/LICENSE.md @@ -1,19 +1,12 @@ -goracle +godror ======= -Copyright 2017 Tamás Gulácsi +Copyright 2017, 2018, 2019 Tamás Gulácsi -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +You can use either the + Apache License, Version 2.0 (APL-2.0), +or the + Universal Permissive License, Version 1.0 (UPL-1.0). ODPI-C ====== diff --git a/vendor/gopkg.in/goracle.v2/NOTES.md b/vendor/github.com/godror/godror/NOTES.md similarity index 100% rename from vendor/gopkg.in/goracle.v2/NOTES.md rename to vendor/github.com/godror/godror/NOTES.md diff --git a/vendor/gopkg.in/goracle.v2/README.md b/vendor/github.com/godror/godror/README.md similarity index 72% rename from vendor/gopkg.in/goracle.v2/README.md rename to vendor/github.com/godror/godror/README.md index 8673ff1a789..97697086919 100644 --- a/vendor/gopkg.in/goracle.v2/README.md +++ b/vendor/github.com/godror/godror/README.md @@ -1,25 +1,29 @@ -[![Build Status](https://travis-ci.org/go-goracle/goracle.svg?branch=v2)](https://travis-ci.org/go-goracle/goracle) -[![GoDoc](https://godoc.org/gopkg.in/goracle.v2?status.svg)](http://godoc.org/gopkg.in/goracle.v2) -[![Go Report Card](https://goreportcard.com/badge/github.com/go-goracle/goracle)](https://goreportcard.com/report/github.com/go-goracle/goracle) -[![codecov](https://codecov.io/gh/go-goracle/goracle/branch/master/graph/badge.svg)](https://codecov.io/gh/go-goracle/goracle) +[![Travis](https://travis-ci.org/godror/godror.svg?branch=v2)](https://travis-ci.org/godror/godror) +[![CircleCI](https://circleci.com/gh/godror/godror.svg?style=svg)](https://circleci.com/gh/godror/godror) +[![GoDoc](https://godoc.org/github.com/godror/godror?status.svg)](http://godoc.org/github.com/godror/godror) +[![Go Report Card](https://goreportcard.com/badge/github.com/godror/godror)](https://goreportcard.com/report/github.com/godror/godror) +[![codecov](https://codecov.io/gh/godror/godror/branch/master/graph/badge.svg)](https://codecov.io/gh/godror/godror) -# goracle +# Go DRiver for ORacle -[goracle](driver.go) is a package which is a +[godror](https://godoc.org/pkg/github.com/godror/godror) is a package which is a [database/sql/driver.Driver](http://golang.org/pkg/database/sql/driver/#Driver) for connecting to Oracle DB, using Anthony Tuininga's excellent OCI wrapper, [ODPI-C](https://www.github.com/oracle/odpi). At least Go 1.11 is required! +Although an Oracle client is NOT required for compiling, it is at run time. +One can download it from https://www.oracle.com/database/technologies/instant-client/downloads.html + ## Connect -In `sql.Open("goracle", connString)`, you can provide the classic "user/passw@service_name" +In `sql.Open("godror", connString)`, you can provide the classic "user/passw@service_name" as connString, or an URL like "oracle://user:passw@service_name". You can provide all possible options with `ConnectionParams`. Watch out the `ConnectionParams.String()` does redact the password -(for security, to avoid logging it - see https://github.com/go-goracle/goracle/issues/79). +(for security, to avoid logging it - see https://github.com/godror/godror/issues/79). So use `ConnectionParams.StringWithPassword()`. More advanced configurations can be set with a connection string such as: @@ -29,22 +33,22 @@ A configuration like this is how you would add functionality such as load balanc described in parenthesis above can also be set in the `SID` field of `ConnectionParams`. For other possible connection strings, see https://oracle.github.io/node-oracledb/doc/api.html#connectionstrings -and https://docs.oracle.com/en/database/oracle/oracle-database/12.2/netag/configuring-naming-methods.html#GUID-B0437826-43C1-49EC-A94D-B650B6A4A6EE . +and https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-B0437826-43C1-49EC-A94D-B650B6A4A6EE . TL;DR; the short form is `username@[//]host[:port][/service_name][:server][/instance_name]`, the long form is `(DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=port)) (CONNECT_DATA= (SERVICE_NAME=service_name) (SERVER=server) (INSTANCE_NAME=instance_name)))`. To use heterogeneous pools, set `heterogeneousPool=1` and provide the username/password through -`goracle.ContextWithUserPassw`. +`godror.ContextWithUserPassw`. ## Rationale With Go 1.9, driver-specific things are not needed, everything (I need) can be achieved with the standard _database/sql_ library. Even calling stored procedures with OUT parameters, or sending/retrieving PL/SQL array types - just give a -`goracle.PlSQLArrays` Option within the parameters of `Exec`! +`godror.PlSQLArrays` Option within the parameters of `Exec`! -The array size of the returned PL/SQL arrays can be set with `goracle.ArraySize(2000)` +The array size of the returned PL/SQL arrays can be set with `godror.ArraySize(2000)` * the default is 1024. @@ -56,7 +60,7 @@ Correctness and simplicity is more important than speed, but the underlying ODPI helps a lot with the lower levels, so the performance is not bad. Queries are prefetched (256 rows by default, can be changed by adding a -`goracle.FetchRowCount(1000)` argument to the call of Query), +`godror.FetchRowCount(1000)` argument to the call of Query), but you can speed up INSERT/UPDATE/DELETE statements by providing all the subsequent parameters at once, by putting each param's subsequent elements in a separate slice: @@ -72,28 +76,28 @@ do ## Logging -Goracle uses `github.com/go-kit/kit/log`'s concept of a `Log` function. -Either set `goracle.Log` to a logging function globally, +godror uses `github.com/go-kit/kit/log`'s concept of a `Log` function. +Either set `godror.Log` to a logging function globally, or (better) set the logger in the Context of ExecContext or QueryContext: - db.QueryContext(goracle.ContextWithLog(ctx, logger.Log), qry) + db.QueryContext(godror.ContextWithLog(ctx, logger.Log), qry) ## Tracing To set ClientIdentifier, ClientInfo, Module, Action and DbOp on the session, -to be seen in the Database by the Admin, set goracle.TraceTag on the Context: +to be seen in the Database by the Admin, set godror.TraceTag on the Context: - db.QueryContext(goracle.ContextWithTraceTag(goracle.TraceTag{ + db.QueryContext(godror.ContextWithTraceTag(godror.TraceTag{ Module: "processing", Action: "first", }), qry) ## Extras -To use the goracle-specific functions, you'll need a `*goracle.conn`. -That's what `goracle.DriverConn` is for! +To use the godror-specific functions, you'll need a `*godror.conn`. +That's what `godror.DriverConn` is for! See [z_qrcn_test.go](./z_qrcn_test.go) for using that to reach -[NewSubscription](https://godoc.org/gopkg.in/goracle.v2#Subscription). +[NewSubscription](https://godoc.org/github.com/godror/godror#Subscription). ### Calling stored procedures Use `ExecContext` and mark each OUT parameter with `sql.Out`. @@ -101,7 +105,7 @@ Use `ExecContext` and mark each OUT parameter with `sql.Out`. ### Using cursors returned by stored procedures Use `ExecContext` and an `interface{}` or a `database/sql/driver.Rows` as the `sql.Out` destination, then either use the `driver.Rows` interface, -or transform it into a regular `*sql.Rows` with `goracle.WrapRows`, +or transform it into a regular `*sql.Rows` with `godror.WrapRows`, or (since Go 1.12) just Scan into `*sql.Rows`. For examples, see Anthony Tuininga's @@ -124,7 +128,7 @@ Just use plain old `string` ! ### NUMBER -`NUMBER`s are transferred as `goracle.Number` (which is a `string`) to Go under the hood. +`NUMBER`s are transferred as `godror.Number` (which is a `string`) to Go under the hood. This ensures that we don't lose any precision (Oracle's NUMBER has 38 decimal digits), and `sql.Scan` will hide this and `Scan` into your `int64`, `float64` or `string`, as you wish. @@ -158,11 +162,11 @@ See #121. Just - go get gopkg.in/goracle.v2 + go get github.com/godror/godror Or if you prefer `dep` - dep ensure -add gopkg.in/goracle.v2 + dep ensure -add github.com/godror/godror and you're ready to go! @@ -173,14 +177,14 @@ Note that Windows may need some newer gcc (mingw-w64 with gcc 7.2.0). Just as with other Go projects, you don't want to change the import paths, but you can hack on the library in place, just set up different remotes: - cd $GOPATH.src/gopkg.in/goracle.v2 - git remote add upstream https://github.com/go-goracle/goracle.git + cd $GOPATH.src/github.com/godror/godror + git remote add upstream https://github.com/godror/godror.git git fetch upstream git checkout -b master upstream/master git checkout -f master git pull upstream master - git remote add fork git@github.com:mygithubacc/goracle + git remote add fork git@github.com:mygithubacc/godror git checkout -b newfeature upstream/master Change, experiment as you wish, then @@ -188,7 +192,7 @@ Change, experiment as you wish, then git commit -m 'my great changes' *.go git push fork newfeature -and you're ready to send a GitHub Pull Request from `github.com/mygithubacc/goracle`, `newfeature` branch. +and you're ready to send a GitHub Pull Request from `github.com/mygithubacc/godror`, `newfeature` branch. ### pre-commit diff --git a/vendor/gopkg.in/goracle.v2/conn.go b/vendor/github.com/godror/godror/conn.go similarity index 68% rename from vendor/gopkg.in/goracle.v2/conn.go rename to vendor/github.com/godror/godror/conn.go index e5a9bb6c3a2..2f5db308c2d 100644 --- a/vendor/gopkg.in/goracle.v2/conn.go +++ b/vendor/github.com/godror/godror/conn.go @@ -1,19 +1,9 @@ // Copyright 2019 Tamás Gulácsi // // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-License-Identifier: UPL-1.0 OR Apache-2.0 -package goracle +package godror /* #include @@ -22,16 +12,18 @@ package goracle import "C" import ( + "bytes" "context" "database/sql" "database/sql/driver" "io" + "strconv" "strings" "sync" "time" "unsafe" - "github.com/pkg/errors" + errors "golang.org/x/xerrors" ) const getConnection = "--GET_CONNECTION--" @@ -40,7 +32,7 @@ const wrapResultset = "--WRAP_RESULTSET--" // The maximum capacity is limited to (2^32 / sizeof(dpiData))-1 to remain compatible // with 32-bit platforms. The size of a `C.dpiData` is 32 Byte on a 64-bit system, `C.dpiSubscrMessageTable` is 40 bytes. // So this is 2^25. -// See https://github.com/go-goracle/goracle/issues/73#issuecomment-401281714 +// See https://github.com/go-godror/godror/issues/73#issuecomment-401281714 const maxArraySize = (1<<30)/C.sizeof_dpiSubscrMessageTable - 1 var _ = driver.Conn((*conn)(nil)) @@ -48,19 +40,22 @@ var _ = driver.ConnBeginTx((*conn)(nil)) var _ = driver.ConnPrepareContext((*conn)(nil)) var _ = driver.Pinger((*conn)(nil)) +//var _ = driver.ExecerContext((*conn)(nil)) + type conn struct { - connParams ConnectionParams currentTT TraceTag + connParams ConnectionParams Client, Server VersionInfo tranParams tranParams - sync.RWMutex - currentUser string - *drv - dpiConn *C.dpiConn - inTransaction bool - newSession bool - timeZone *time.Location - tzOffSecs int + mu sync.RWMutex + currentUser string + drv *drv + dpiConn *C.dpiConn + timeZone *time.Location + objTypes map[string]ObjectType + tzOffSecs int + inTransaction bool + newSession bool } func (c *conn) getError() error { @@ -71,17 +66,19 @@ func (c *conn) getError() error { } func (c *conn) Break() error { - c.RLock() - defer c.RUnlock() + c.mu.RLock() + defer c.mu.RUnlock() if Log != nil { Log("msg", "Break", "dpiConn", c.dpiConn) } if C.dpiConn_breakExecution(c.dpiConn) == C.DPI_FAILURE { - return maybeBadConn(errors.Wrap(c.getError(), "Break")) + return maybeBadConn(errors.Errorf("Break: %w", c.getError()), c) } return nil } +func (c *conn) ClientVersion() (VersionInfo, error) { return c.drv.ClientVersion() } + // Ping checks the connection's state. // // WARNING: as database/sql calls database/sql/driver.Open when it needs @@ -95,14 +92,14 @@ func (c *conn) Ping(ctx context.Context) error { if err := c.ensureContextUser(ctx); err != nil { return err } - c.RLock() - defer c.RUnlock() + c.mu.RLock() + defer c.mu.RUnlock() done := make(chan error, 1) go func() { defer close(done) failure := C.dpiConn_ping(c.dpiConn) == C.DPI_FAILURE if failure { - done <- maybeBadConn(errors.Wrap(c.getError(), "Ping")) + done <- maybeBadConn(errors.Errorf("Ping: %w", c.getError()), c) return } done <- nil @@ -118,6 +115,7 @@ func (c *conn) Ping(ctx context.Context) error { return err default: _ = c.Break() + c.close(true) return driver.ErrBadConn } } @@ -140,30 +138,51 @@ func (c *conn) Close() error { if c == nil { return nil } - c.Lock() - defer c.Unlock() + c.mu.Lock() + defer c.mu.Unlock() + return c.close(true) +} + +func (c *conn) close(doNotReuse bool) error { + if c == nil { + return nil + } c.setTraceTag(TraceTag{}) - dpiConn := c.dpiConn - c.dpiConn = nil + dpiConn, objTypes := c.dpiConn, c.objTypes + c.dpiConn, c.objTypes = nil, nil if dpiConn == nil { return nil } + defer C.dpiConn_release(dpiConn) + + seen := make(map[string]struct{}, len(objTypes)) + for _, o := range objTypes { + nm := o.FullName() + if _, seen := seen[nm]; seen { + continue + } + seen[nm] = struct{}{} + o.close(doNotReuse) + } + if !doNotReuse { + return nil + } + // Just to be sure, break anything in progress. done := make(chan struct{}) go func() { select { case <-done: case <-time.After(10 * time.Second): + if Log != nil { + Log("msg", "TIMEOUT releasing connection") + } C.dpiConn_breakExecution(dpiConn) } }() - rc := C.dpiConn_release(dpiConn) + C.dpiConn_close(dpiConn, C.DPI_MODE_CONN_CLOSE_DROP, nil, 0) close(done) - var err error - if rc == C.DPI_FAILURE { - err = maybeBadConn(errors.Wrap(c.getError(), "Close")) - } - return err + return nil } // Begin starts and returns a new transaction. @@ -210,7 +229,7 @@ func (c *conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, e case sql.LevelSerializable: todo.Level = trLS default: - return nil, errors.Errorf("%v isolation level is not supported", sql.IsolationLevel(opts.Isolation)) + return nil, errors.Errorf("isolation level is not supported: %s", sql.IsolationLevel(opts.Isolation)) } if todo != c.tranParams { @@ -229,25 +248,25 @@ func (c *conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, e stmt.Close() } if err != nil { - return nil, maybeBadConn(errors.Wrap(err, qry)) + return nil, maybeBadConn(errors.Errorf("%s: %w", qry, err), c) } } c.tranParams = todo } - c.RLock() + c.mu.RLock() inTran := c.inTransaction - c.RUnlock() + c.mu.RUnlock() if inTran { return nil, errors.New("already in transaction") } - c.Lock() + c.mu.Lock() c.inTransaction = true - c.Unlock() + c.mu.Unlock() if tt, ok := ctx.Value(traceTagCtxKey).(TraceTag); ok { - c.Lock() + c.mu.Lock() c.setTraceTag(tt) - c.Unlock() + c.mu.Unlock() } return c, nil } @@ -267,9 +286,9 @@ func (c *conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, e return nil, err } if tt, ok := ctx.Value(traceTagCtxKey).(TraceTag); ok { - c.Lock() + c.mu.Lock() c.setTraceTag(tt) - c.Unlock() + c.mu.Unlock() } if query == getConnection { if Log != nil { @@ -282,13 +301,13 @@ func (c *conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, e defer func() { C.free(unsafe.Pointer(cSQL)) }() - c.RLock() - defer c.RUnlock() + c.mu.RLock() + defer c.mu.RUnlock() var dpiStmt *C.dpiStmt if C.dpiConn_prepareStmt(c.dpiConn, 0, cSQL, C.uint32_t(len(query)), nil, 0, (**C.dpiStmt)(unsafe.Pointer(&dpiStmt)), ) == C.DPI_FAILURE { - return nil, maybeBadConn(errors.Wrap(c.getError(), "Prepare: "+query)) + return nil, maybeBadConn(errors.Errorf("Prepare: %s: %w", query, c.getError()), c) } return &statement{conn: c, dpiStmt: dpiStmt, query: query}, nil } @@ -299,7 +318,7 @@ func (c *conn) Rollback() error { return c.endTran(false) } func (c *conn) endTran(isCommit bool) error { - c.Lock() + c.mu.Lock() c.inTransaction = false c.tranParams = tranParams{} @@ -307,15 +326,15 @@ func (c *conn) endTran(isCommit bool) error { //msg := "Commit" if isCommit { if C.dpiConn_commit(c.dpiConn) == C.DPI_FAILURE { - err = maybeBadConn(errors.Wrap(c.getError(), "Commit")) + err = maybeBadConn(errors.Errorf("Commit: %w", c.getError()), c) } } else { //msg = "Rollback" if C.dpiConn_rollback(c.dpiConn) == C.DPI_FAILURE { - err = maybeBadConn(errors.Wrap(c.getError(), "Rollback")) + err = maybeBadConn(errors.Errorf("Rollback: %w", c.getError()), c) } } - c.Unlock() + c.mu.Unlock() //fmt.Printf("%p.%s\n", c, msg) return err } @@ -350,7 +369,7 @@ func (c *conn) newVar(vi varInfo) (*C.dpiVar, []C.dpiData, error) { isArray, vi.ObjectType, &v, &dataArr, ) == C.DPI_FAILURE { - return nil, nil, errors.Wrapf(c.getError(), "newVar(typ=%d, natTyp=%d, sliceLen=%d, bufSize=%d)", vi.Typ, vi.NatTyp, vi.SliceLen, vi.BufSize) + return nil, nil, errors.Errorf("newVar(typ=%d, natTyp=%d, sliceLen=%d, bufSize=%d): %w", vi.Typ, vi.NatTyp, vi.SliceLen, vi.BufSize, c.getError()) } // https://github.com/golang/go/wiki/cgo#Turning_C_arrays_into_Go_slices /* @@ -368,71 +387,184 @@ func (c *conn) ServerVersion() (VersionInfo, error) { return c.Server, nil } -func (c *conn) init() error { +func (c *conn) init(onInit []string) error { if c.Client.Version == 0 { var err error if c.Client, err = c.drv.ClientVersion(); err != nil { return err } } + + if err := c.initVersionTZ(); err != nil || len(onInit) == 0 || !c.newSession { + return err + } + if Log != nil { + Log("newSession", c.newSession, "onInit", onInit) + } + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Duration(len(onInit))*time.Second) + defer cancel() + if Log != nil { + Log("doOnInit", len(onInit)) + } + for _, qry := range onInit { + if Log != nil { + Log("onInit", qry) + } + st, err := c.PrepareContext(ctx, qry) + if err != nil { + return errors.Errorf("%s: %w", qry, err) + } + _, err = st.Exec(nil) //lint:ignore SA1019 - it's hard to use ExecContext here + st.Close() + if err != nil { + return errors.Errorf("%s: %w", qry, err) + } + } + return nil + } + +func (c *conn) initVersionTZ() error { if c.Server.Version == 0 { var v C.dpiVersionInfo var release *C.char var releaseLen C.uint32_t if C.dpiConn_getServerVersion(c.dpiConn, &release, &releaseLen, &v) == C.DPI_FAILURE { - return errors.Wrap(c.getError(), "getServerVersion") + if c.connParams.IsPrelim { + return nil + } + return errors.Errorf("getServerVersion: %w", c.getError()) } c.Server.set(&v) - c.Server.ServerRelease = C.GoStringN(release, C.int(releaseLen)) + c.Server.ServerRelease = string(bytes.Replace( + ((*[maxArraySize]byte)(unsafe.Pointer(release)))[:releaseLen:releaseLen], + []byte{'\n'}, []byte{';', ' '}, -1)) } - if c.timeZone != nil { + if c.timeZone != nil && (c.timeZone != time.Local || c.tzOffSecs != 0) { return nil } c.timeZone = time.Local - _, c.tzOffSecs = (time.Time{}).In(c.timeZone).Zone() + _, c.tzOffSecs = time.Now().In(c.timeZone).Zone() + if Log != nil { + Log("tz", c.timeZone, "offSecs", c.tzOffSecs) + } - const qry = "SELECT DBTIMEZONE FROM DUAL" + // DBTIMEZONE is useless, false, and misdirecting! + // https://stackoverflow.com/questions/52531137/sysdate-and-dbtimezone-different-in-oracle-database + const qry = "SELECT DBTIMEZONE, LTRIM(REGEXP_SUBSTR(TO_CHAR(SYSTIMESTAMP), ' [^ ]+$')) FROM DUAL" ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) defer cancel() st, err := c.PrepareContext(ctx, qry) if err != nil { - return errors.Wrap(err, qry) + return errors.Errorf("%s: %w", qry, err) } defer st.Close() - rows, err := st.Query([]driver.Value{}) + rows, err := st.Query(nil) //lint:ignore SA1019 - it's hard to use QueryContext here if err != nil { - return errors.Wrap(err, qry) + if Log != nil { + Log("qry", qry, "error", err) + } + return nil } defer rows.Close() - var timezone string - vals := []driver.Value{timezone} - for { - if err = rows.Next(vals); err != nil { - if err == io.EOF { - break + var dbTZ, timezone string + vals := []driver.Value{dbTZ, timezone} + if err = rows.Next(vals); err != nil && err != io.EOF { + return errors.Errorf("%s: %w", qry, err) + } + dbTZ = vals[0].(string) + timezone = vals[1].(string) + + tz, off, err := calculateTZ(dbTZ, timezone) + if Log != nil { + Log("timezone", timezone, "tz", tz, "offSecs", off) + } + if err != nil || tz == nil { + return err + } + c.timeZone, c.tzOffSecs = tz, off + + return nil +} + +func calculateTZ(dbTZ, timezone string) (*time.Location, int, error) { + if Log != nil { + Log("dbTZ", dbTZ, "timezone", timezone) + } + var tz *time.Location + now := time.Now() + _, localOff := time.Now().Local().Zone() + off := localOff + var ok bool + var err error + if dbTZ != "" && strings.Contains(dbTZ, "/") { + tz, err = time.LoadLocation(dbTZ) + if ok = err == nil; ok { + if tz == time.Local { + return tz, off, nil } - return errors.Wrap(err, qry) + _, off = now.In(tz).Zone() + } else if Log != nil { + Log("LoadLocation", dbTZ, "error", err) } - timezone = strings.TrimSpace(vals[0].(string)) + } + if !ok { if timezone != "" { - break + if off, err = parseTZ(timezone); err != nil { + return tz, off, errors.Errorf("%s: %w", timezone, err) + } + } else if off, err = parseTZ(dbTZ); err != nil { + return tz, off, errors.Errorf("%s: %w", dbTZ, err) } } - if timezone == "" { - return errors.New("empty DBTIMEZONE") + // This is dangerous, but I just cannot get whether the DB time zone + // setting has DST or not - DBTIMEZONE returns just a fixed offset. + if off != localOff && tz == nil { + tz = time.FixedZone(timezone, off) + } + return tz, off, nil +} +func parseTZ(s string) (int, error) { + s = strings.TrimSpace(s) + if s == "" { + return 0, io.EOF + } + if s == "Z" || s == "UTC" { + return 0, nil + } + var tz int + var ok bool + if i := strings.IndexByte(s, ':'); i >= 0 { + if i64, err := strconv.ParseInt(s[i+1:], 10, 6); err != nil { + return tz, errors.Errorf("%s: %w", s, err) + } else { + tz = int(i64 * 60) + } + s = s[:i] + ok = true } - if off, err := parseTZ(timezone); err != nil { - return errors.Wrap(err, timezone) + if !ok { + if i := strings.IndexByte(s, '/'); i >= 0 { + targetLoc, err := time.LoadLocation(s) + if err != nil { + return tz, errors.Errorf("%s: %w", s, err) + } + + _, localOffset := time.Now().In(targetLoc).Zone() + + tz = localOffset + return tz, nil + } + } + if i64, err := strconv.ParseInt(s, 10, 5); err != nil { + return tz, errors.Errorf("%s: %w", s, err) } else { - // This is dangerous, but I just cannot get whether the DB time zone - // setting has DST or not - DBTIMEZONE returns just a fixed offset. - if _, localOff := time.Now().Local().Zone(); localOff != off { - c.tzOffSecs = off - c.timeZone = time.FixedZone(timezone, c.tzOffSecs) + if i64 < 0 { + tz = -tz } + tz += int(i64 * 3600) } - return nil + return tz, nil } func (c *conn) setCallTimeout(ctx context.Context) { @@ -447,21 +579,34 @@ func (c *conn) setCallTimeout(ctx context.Context) { C.dpiConn_setCallTimeout(c.dpiConn, ms) } -func maybeBadConn(err error) error { +// maybeBadConn checks whether the error is because of a bad connection, and returns driver.ErrBadConn, +// as database/sql requires. +// +// Also in this case, iff c != nil, closes it. +func maybeBadConn(err error, c *conn) error { if err == nil { return nil } - root := errors.Cause(err) - if root == driver.ErrBadConn { - return root + cl := func() {} + if c != nil { + cl = func() { + if Log != nil { + Log("msg", "maybeBadConn close", "conn", c) + } + c.close(true) + } + } + if errors.Is(err, driver.ErrBadConn) { + cl() + return driver.ErrBadConn } - if cd, ok := root.(interface { - Code() int - }); ok { + var cd interface{ Code() int } + if errors.As(err, &cd) { // Yes, this is copied from rana/ora, but I've put it there, so it's mine. @tgulacsi switch cd.Code() { case 0: if strings.Contains(err.Error(), " DPI-1002: ") { + cl() return driver.ErrBadConn } // cases by experience: @@ -500,6 +645,7 @@ func maybeBadConn(err error) error { 27146, // post/wait initialization failed 28511, // lost RPC connection 56600: // an illegal OCI function call was issued + cl() return driver.ErrBadConn } } @@ -542,7 +688,7 @@ func (c *conn) setTraceTag(tt TraceTag) error { C.free(unsafe.Pointer(s)) } if rc == C.DPI_FAILURE { - return errors.Wrap(c.getError(), nm) + return errors.Errorf("%s: %w", nm, c.getError()) } } c.currentTT = tt @@ -576,35 +722,26 @@ const userpwCtxKey = ctxKey("userPw") // ContextWithUserPassw returns a context with the specified user and password, // to be used with heterogeneous pools. -func ContextWithUserPassw(ctx context.Context, user, password string) context.Context { - return context.WithValue(ctx, userpwCtxKey, [2]string{user, password}) +func ContextWithUserPassw(ctx context.Context, user, password, connClass string) context.Context { + return context.WithValue(ctx, userpwCtxKey, [3]string{user, password, connClass}) } func (c *conn) ensureContextUser(ctx context.Context) error { - if !c.connParams.HeterogeneousPool { + if !(c.connParams.HeterogeneousPool || c.connParams.StandaloneConnection) { return nil } - - var up [2]string - var ok bool - if up, ok = ctx.Value(userpwCtxKey).([2]string); !ok || up[0] == c.currentUser { + up, ok := ctx.Value(userpwCtxKey).([3]string) + if !ok || up[0] == c.currentUser { return nil } if c.dpiConn != nil { - if err := c.Close(); err != nil { + if err := c.close(false); err != nil { return driver.ErrBadConn } } - c.Lock() - defer c.Unlock() - - if err := c.acquireConn(up[0], up[1]); err != nil { - return err - } - - return c.init() + return c.acquireConn(up[0], up[1], up[2]) } // StartupMode for the database. @@ -625,7 +762,7 @@ const ( // See https://docs.oracle.com/en/database/oracle/oracle-database/18/lnoci/database-startup-and-shutdown.html#GUID-44B24F65-8C24-4DF3-8FBF-B896A4D6F3F3 func (c *conn) Startup(mode StartupMode) error { if C.dpiConn_startupDatabase(c.dpiConn, C.dpiStartupMode(mode)) == C.DPI_FAILURE { - return errors.Wrapf(c.getError(), "startup(%v)", mode) + return errors.Errorf("startup(%v): %w", mode, c.getError()) } return nil } @@ -654,7 +791,12 @@ const ( // See https://docs.oracle.com/en/database/oracle/oracle-database/18/lnoci/database-startup-and-shutdown.html#GUID-44B24F65-8C24-4DF3-8FBF-B896A4D6F3F3 func (c *conn) Shutdown(mode ShutdownMode) error { if C.dpiConn_shutdownDatabase(c.dpiConn, C.dpiShutdownMode(mode)) == C.DPI_FAILURE { - return errors.Wrapf(c.getError(), "shutdown(%v)", mode) + return errors.Errorf("shutdown(%v): %w", mode, c.getError()) } return nil } + +// Timezone returns the connection's timezone. +func (c *conn) Timezone() *time.Location { + return c.timeZone +} diff --git a/vendor/github.com/godror/godror/contrib/free.db/cwallet.sso b/vendor/github.com/godror/godror/contrib/free.db/cwallet.sso new file mode 100644 index 00000000000..c9eeffc2ffe Binary files /dev/null and b/vendor/github.com/godror/godror/contrib/free.db/cwallet.sso differ diff --git a/vendor/github.com/godror/godror/contrib/free.db/env.sh b/vendor/github.com/godror/godror/contrib/free.db/env.sh new file mode 100644 index 00000000000..02c93a50d9a --- /dev/null +++ b/vendor/github.com/godror/godror/contrib/free.db/env.sh @@ -0,0 +1,5 @@ +export TNS_ADMIN="$(dirname "$(find "$PWD" -type f -name tnsnames.ora | sort -r | head -n1)")" +export GODROR_TEST_USERNAME=test +export GODROR_TEST_PASSWORD=r97oUPimsmTOIcBaeeDF +export GODROR_TEST_DB=free_high +export GODROR_TEST_STANDALONE=1 diff --git a/vendor/github.com/godror/godror/contrib/free.db/ewallet.p12 b/vendor/github.com/godror/godror/contrib/free.db/ewallet.p12 new file mode 100644 index 00000000000..b7a8ff0450d Binary files /dev/null and b/vendor/github.com/godror/godror/contrib/free.db/ewallet.p12 differ diff --git a/vendor/github.com/godror/godror/contrib/free.db/keystore.jks b/vendor/github.com/godror/godror/contrib/free.db/keystore.jks new file mode 100644 index 00000000000..1923759914e Binary files /dev/null and b/vendor/github.com/godror/godror/contrib/free.db/keystore.jks differ diff --git a/vendor/github.com/godror/godror/contrib/free.db/ojdbc.properties b/vendor/github.com/godror/godror/contrib/free.db/ojdbc.properties new file mode 100644 index 00000000000..9fc350ca425 --- /dev/null +++ b/vendor/github.com/godror/godror/contrib/free.db/ojdbc.properties @@ -0,0 +1 @@ +oracle.net.wallet_location=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=${TNS_ADMIN}))) \ No newline at end of file diff --git a/vendor/github.com/godror/godror/contrib/free.db/reset.sql b/vendor/github.com/godror/godror/contrib/free.db/reset.sql new file mode 100644 index 00000000000..c8666143455 --- /dev/null +++ b/vendor/github.com/godror/godror/contrib/free.db/reset.sql @@ -0,0 +1,15 @@ +WHENEVER SQLERROR CONTINUE + +DROP USER test CASCADE; + +WHENEVER SQLERROR EXIT SQL.SQLCODE ROLLBACK + +CREATE USER test IDENTIFIED BY r97oUPimsmTOIcBaeeDF; +ALTER USER test QUOTA 100m ON data; +GRANT create session, create table, create type, create sequence, create synonym, create procedure, change notification TO test; +GRANT EXECUTE ON SYS.DBMS_AQ TO test; +GRANT EXECUTE ON SYS.DBMS_AQADM TO test; + +GRANT create user, drop user, alter user TO test; +GRANT connect TO test WITH admin option; +GRANT create session TO test WITH admin option; diff --git a/vendor/github.com/godror/godror/contrib/free.db/sqlnet.ora b/vendor/github.com/godror/godror/contrib/free.db/sqlnet.ora new file mode 100644 index 00000000000..260f677fcde --- /dev/null +++ b/vendor/github.com/godror/godror/contrib/free.db/sqlnet.ora @@ -0,0 +1,2 @@ +WALLET_LOCATION = (SOURCE = (METHOD = file) (METHOD_DATA = (DIRECTORY="?/network/admin"))) +SSL_SERVER_DN_MATCH=yes \ No newline at end of file diff --git a/vendor/github.com/godror/godror/contrib/free.db/tnsnames.ora b/vendor/github.com/godror/godror/contrib/free.db/tnsnames.ora new file mode 100644 index 00000000000..1b10c58ee0a --- /dev/null +++ b/vendor/github.com/godror/godror/contrib/free.db/tnsnames.ora @@ -0,0 +1,6 @@ +free_high = (description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.eu-frankfurt-1.oraclecloud.com))(connect_data=(service_name=zo0svnycldsrgbw_db201911301540_high.adwc.oraclecloud.com))(security=(ssl_server_cert_dn="CN=adwc.eucom-central-1.oraclecloud.com,OU=Oracle BMCS FRANKFURT,O=Oracle Corporation,L=Redwood City,ST=California,C=US"))) + +free_low = (description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.eu-frankfurt-1.oraclecloud.com))(connect_data=(service_name=zo0svnycldsrgbw_db201911301540_low.adwc.oraclecloud.com))(security=(ssl_server_cert_dn="CN=adwc.eucom-central-1.oraclecloud.com,OU=Oracle BMCS FRANKFURT,O=Oracle Corporation,L=Redwood City,ST=California,C=US"))) + +free_medium = (description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.eu-frankfurt-1.oraclecloud.com))(connect_data=(service_name=zo0svnycldsrgbw_db201911301540_medium.adwc.oraclecloud.com))(security=(ssl_server_cert_dn="CN=adwc.eucom-central-1.oraclecloud.com,OU=Oracle BMCS FRANKFURT,O=Oracle Corporation,L=Redwood City,ST=California,C=US"))) + diff --git a/vendor/github.com/godror/godror/contrib/free.db/truststore.jks b/vendor/github.com/godror/godror/contrib/free.db/truststore.jks new file mode 100644 index 00000000000..55faa40478b Binary files /dev/null and b/vendor/github.com/godror/godror/contrib/free.db/truststore.jks differ diff --git a/vendor/github.com/godror/godror/contrib/oracle-instant-client/Dockerfile b/vendor/github.com/godror/godror/contrib/oracle-instant-client/Dockerfile new file mode 100644 index 00000000000..45af9abff4b --- /dev/null +++ b/vendor/github.com/godror/godror/contrib/oracle-instant-client/Dockerfile @@ -0,0 +1,14 @@ +FROM debian:testing + +LABEL maintainer="t.gulacsi@unosoft.hu" + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get update && apt-get install -y libaio1 wget unzip + +RUN wget -O /tmp/instantclient-basic-linux-x64.zip https://download.oracle.com/otn_software/linux/instantclient/193000/instantclient-basic-linux.x64-19.3.0.0.0dbru.zip + +RUN mkdir -p /usr/lib/oracle && unzip /tmp/instantclient-basic-linux-x64.zip -d /usr/lib/oracle + +RUN ldconfig -v /usr/lib/oracle/instantclient_19_3 +RUN ldd /usr/lib/oracle/instantclient_19_3/libclntsh.so diff --git a/vendor/gopkg.in/goracle.v2/contrib/oracle-instant-client/README.md b/vendor/github.com/godror/godror/contrib/oracle-instant-client/README.md similarity index 100% rename from vendor/gopkg.in/goracle.v2/contrib/oracle-instant-client/README.md rename to vendor/github.com/godror/godror/contrib/oracle-instant-client/README.md diff --git a/vendor/gopkg.in/goracle.v2/contrib/oracle-xe-18c/Dockerfile b/vendor/github.com/godror/godror/contrib/oracle-xe-18c/Dockerfile similarity index 100% rename from vendor/gopkg.in/goracle.v2/contrib/oracle-xe-18c/Dockerfile rename to vendor/github.com/godror/godror/contrib/oracle-xe-18c/Dockerfile diff --git a/vendor/gopkg.in/goracle.v2/contrib/oracle-xe-18c/README.md b/vendor/github.com/godror/godror/contrib/oracle-xe-18c/README.md similarity index 100% rename from vendor/gopkg.in/goracle.v2/contrib/oracle-xe-18c/README.md rename to vendor/github.com/godror/godror/contrib/oracle-xe-18c/README.md diff --git a/vendor/github.com/godror/godror/data.go b/vendor/github.com/godror/godror/data.go new file mode 100644 index 00000000000..c42f3ec189a --- /dev/null +++ b/vendor/github.com/godror/godror/data.go @@ -0,0 +1,468 @@ +// Copyright 2017 Tamás Gulácsi +// +// +// SPDX-License-Identifier: UPL-1.0 OR Apache-2.0 + +package godror + +/* +#include +#include "dpiImpl.h" +*/ +import "C" +import ( + "database/sql" + "database/sql/driver" + "fmt" + "reflect" + "time" + "unsafe" + + errors "golang.org/x/xerrors" +) + +// Data holds the data to/from Oracle. +type Data struct { + ObjectType ObjectType + dpiData C.dpiData + implicitObj bool + NativeTypeNum C.dpiNativeTypeNum +} + +var ErrNotSupported = errors.New("not supported") + +// NewData creates a new Data structure for the given type, populated with the given type. +func NewData(v interface{}) (*Data, error) { + if v == nil { + return nil, errors.Errorf("%s: %w", "nil type", ErrNotSupported) + } + data := Data{dpiData: C.dpiData{isNull: 1}} + return &data, data.Set(v) +} + +// IsNull returns whether the data is null. +func (d *Data) IsNull() bool { + // Use of C.dpiData_getIsNull(&d.dpiData) would be safer, + // but ODPI-C 3.1.4 just returns dpiData->isNull, so do the same + // without calling CGO. + return d == nil || d.dpiData.isNull == 1 +} + +// SetNull sets the value of the data to be the null value. +func (d *Data) SetNull() { + if !d.IsNull() { + // Maybe C.dpiData_setNull(&d.dpiData) would be safer, but as we don't use C.dpiData_getIsNull, + // and those functions (at least in ODPI-C 3.1.4) just operate on data->isNull directly, + // don't use CGO if possible. + d.dpiData.isNull = 1 + } +} + +// GetBool returns the bool data. +func (d *Data) GetBool() bool { + return !d.IsNull() && C.dpiData_getBool(&d.dpiData) == 1 +} + +// SetBool sets the data as bool. +func (d *Data) SetBool(b bool) { + var i C.int + if b { + i = 1 + } + C.dpiData_setBool(&d.dpiData, i) +} + +// GetBytes returns the []byte from the data. +func (d *Data) GetBytes() []byte { + if d.IsNull() { + return nil + } + b := C.dpiData_getBytes(&d.dpiData) + if b.ptr == nil || b.length == 0 { + return nil + } + return ((*[32767]byte)(unsafe.Pointer(b.ptr)))[:b.length:b.length] +} + +// SetBytes set the data as []byte. +func (d *Data) SetBytes(b []byte) { + if b == nil { + d.dpiData.isNull = 1 + return + } + C.dpiData_setBytes(&d.dpiData, (*C.char)(unsafe.Pointer(&b[0])), C.uint32_t(len(b))) +} + +// GetFloat32 gets float32 from the data. +func (d *Data) GetFloat32() float32 { + if d.IsNull() { + return 0 + } + return float32(C.dpiData_getFloat(&d.dpiData)) +} + +// SetFloat32 sets the data as float32. +func (d *Data) SetFloat32(f float32) { + C.dpiData_setFloat(&d.dpiData, C.float(f)) +} + +// GetFloat64 gets float64 from the data. +func (d *Data) GetFloat64() float64 { + //fmt.Println("GetFloat64", d.IsNull(), d) + if d.IsNull() { + return 0 + } + return float64(C.dpiData_getDouble(&d.dpiData)) +} + +// SetFloat64 sets the data as float64. +func (d *Data) SetFloat64(f float64) { + C.dpiData_setDouble(&d.dpiData, C.double(f)) +} + +// GetInt64 gets int64 from the data. +func (d *Data) GetInt64() int64 { + if d.IsNull() { + return 0 + } + return int64(C.dpiData_getInt64(&d.dpiData)) +} + +// SetInt64 sets the data as int64. +func (d *Data) SetInt64(i int64) { + C.dpiData_setInt64(&d.dpiData, C.int64_t(i)) +} + +// GetIntervalDS gets duration as interval date-seconds from data. +func (d *Data) GetIntervalDS() time.Duration { + if d.IsNull() { + return 0 + } + ds := C.dpiData_getIntervalDS(&d.dpiData) + return time.Duration(ds.days)*24*time.Hour + + time.Duration(ds.hours)*time.Hour + + time.Duration(ds.minutes)*time.Minute + + time.Duration(ds.seconds)*time.Second + + time.Duration(ds.fseconds) +} + +// SetIntervalDS sets the duration as interval date-seconds to data. +func (d *Data) SetIntervalDS(dur time.Duration) { + C.dpiData_setIntervalDS(&d.dpiData, + C.int32_t(int64(dur.Hours())/24), + C.int32_t(int64(dur.Hours())%24), C.int32_t(dur.Minutes()), C.int32_t(dur.Seconds()), + C.int32_t(dur.Nanoseconds()), + ) +} + +// GetIntervalYM gets IntervalYM from the data. +func (d *Data) GetIntervalYM() IntervalYM { + if d.IsNull() { + return IntervalYM{} + } + ym := C.dpiData_getIntervalYM(&d.dpiData) + return IntervalYM{Years: int(ym.years), Months: int(ym.months)} +} + +// SetIntervalYM sets IntervalYM to the data. +func (d *Data) SetIntervalYM(ym IntervalYM) { + C.dpiData_setIntervalYM(&d.dpiData, C.int32_t(ym.Years), C.int32_t(ym.Months)) +} + +// GetLob gets data as Lob. +func (d *Data) GetLob() *Lob { + if d.IsNull() { + return nil + } + return &Lob{Reader: &dpiLobReader{dpiLob: C.dpiData_getLOB(&d.dpiData)}} +} + +// SetLob sets Lob to the data. +func (d *Data) SetLob(lob *DirectLob) { + C.dpiData_setLOB(&d.dpiData, lob.dpiLob) +} + +// GetObject gets Object from data. +// +// As with all Objects, you MUST call Close on it when not needed anymore! +func (d *Data) GetObject() *Object { + if d == nil { + panic("null") + } + if d.IsNull() { + return nil + } + + o := C.dpiData_getObject(&d.dpiData) + if o == nil { + return nil + } + if !d.implicitObj { + if C.dpiObject_addRef(o) == C.DPI_FAILURE { + panic(d.ObjectType.getError()) + } + } + obj := &Object{dpiObject: o, ObjectType: d.ObjectType} + obj.init() + return obj +} + +// SetObject sets Object to data. +func (d *Data) SetObject(o *Object) { + C.dpiData_setObject(&d.dpiData, o.dpiObject) +} + +// GetStmt gets Stmt from data. +func (d *Data) GetStmt() driver.Stmt { + if d.IsNull() { + return nil + } + return &statement{dpiStmt: C.dpiData_getStmt(&d.dpiData)} +} + +// SetStmt sets Stmt to data. +func (d *Data) SetStmt(s *statement) { + C.dpiData_setStmt(&d.dpiData, s.dpiStmt) +} + +// GetTime gets Time from data. +func (d *Data) GetTime() time.Time { + if d.IsNull() { + return time.Time{} + } + ts := C.dpiData_getTimestamp(&d.dpiData) + return time.Date( + int(ts.year), time.Month(ts.month), int(ts.day), + int(ts.hour), int(ts.minute), int(ts.second), int(ts.fsecond), + timeZoneFor(ts.tzHourOffset, ts.tzMinuteOffset), + ) + +} + +// SetTime sets Time to data. +func (d *Data) SetTime(t time.Time) { + _, z := t.Zone() + C.dpiData_setTimestamp(&d.dpiData, + C.int16_t(t.Year()), C.uint8_t(t.Month()), C.uint8_t(t.Day()), + C.uint8_t(t.Hour()), C.uint8_t(t.Minute()), C.uint8_t(t.Second()), C.uint32_t(t.Nanosecond()), + C.int8_t(z/3600), C.int8_t((z%3600)/60), + ) +} + +// GetUint64 gets data as uint64. +func (d *Data) GetUint64() uint64 { + if d.IsNull() { + return 0 + } + return uint64(C.dpiData_getUint64(&d.dpiData)) +} + +// SetUint64 sets data to uint64. +func (d *Data) SetUint64(u uint64) { + C.dpiData_setUint64(&d.dpiData, C.uint64_t(u)) +} + +// IntervalYM holds Years and Months as interval. +type IntervalYM struct { + Years, Months int +} + +// Get returns the contents of Data. +func (d *Data) Get() interface{} { + switch d.NativeTypeNum { + case C.DPI_NATIVE_TYPE_BOOLEAN: + return d.GetBool() + case C.DPI_NATIVE_TYPE_BYTES: + return d.GetBytes() + case C.DPI_NATIVE_TYPE_DOUBLE: + return d.GetFloat64() + case C.DPI_NATIVE_TYPE_FLOAT: + return d.GetFloat32() + case C.DPI_NATIVE_TYPE_INT64: + return d.GetInt64() + case C.DPI_NATIVE_TYPE_INTERVAL_DS: + return d.GetIntervalDS() + case C.DPI_NATIVE_TYPE_INTERVAL_YM: + return d.GetIntervalYM() + case C.DPI_NATIVE_TYPE_LOB: + return d.GetLob() + case C.DPI_NATIVE_TYPE_OBJECT: + return d.GetObject() + case C.DPI_NATIVE_TYPE_STMT: + return d.GetStmt() + case C.DPI_NATIVE_TYPE_TIMESTAMP: + return d.GetTime() + case C.DPI_NATIVE_TYPE_UINT64: + return d.GetUint64() + default: + panic(fmt.Sprintf("unknown NativeTypeNum=%d", d.NativeTypeNum)) + } +} + +// Set the data. +func (d *Data) Set(v interface{}) error { + if v == nil { + return errors.Errorf("%s: %w", "nil type", ErrNotSupported) + } + switch x := v.(type) { + case int32: + d.NativeTypeNum = C.DPI_NATIVE_TYPE_INT64 + d.SetInt64(int64(x)) + case int64: + d.NativeTypeNum = C.DPI_NATIVE_TYPE_INT64 + d.SetInt64(x) + case uint64: + d.NativeTypeNum = C.DPI_NATIVE_TYPE_UINT64 + d.SetUint64(x) + case float32: + d.NativeTypeNum = C.DPI_NATIVE_TYPE_FLOAT + d.SetFloat32(x) + case float64: + d.NativeTypeNum = C.DPI_NATIVE_TYPE_DOUBLE + d.SetFloat64(x) + case string: + d.NativeTypeNum = C.DPI_NATIVE_TYPE_BYTES + d.SetBytes([]byte(x)) + case []byte: + d.NativeTypeNum = C.DPI_NATIVE_TYPE_BYTES + d.SetBytes(x) + case time.Time: + d.NativeTypeNum = C.DPI_NATIVE_TYPE_TIMESTAMP + d.SetTime(x) + case time.Duration: + d.NativeTypeNum = C.DPI_NATIVE_TYPE_INTERVAL_DS + d.SetIntervalDS(x) + case IntervalYM: + d.NativeTypeNum = C.DPI_NATIVE_TYPE_INTERVAL_YM + d.SetIntervalYM(x) + case *DirectLob: + d.NativeTypeNum = C.DPI_NATIVE_TYPE_LOB + d.SetLob(x) + case *Object: + d.NativeTypeNum = C.DPI_NATIVE_TYPE_OBJECT + d.ObjectType = x.ObjectType + d.SetObject(x) + //case *stmt: + //d.NativeTypeNum = C.DPI_NATIVE_TYPE_STMT + //d.SetStmt(x) + case bool: + d.NativeTypeNum = C.DPI_NATIVE_TYPE_BOOLEAN + d.SetBool(x) + //case rowid: + //d.NativeTypeNum = C.DPI_NATIVE_TYPE_ROWID + //d.SetRowid(x) + default: + return errors.Errorf("%T: %w", ErrNotSupported, v) + } + return nil +} + +// IsObject returns whether the data contains an Object or not. +func (d *Data) IsObject() bool { + return d.NativeTypeNum == C.DPI_NATIVE_TYPE_OBJECT +} + +// NewData returns Data for input parameters on Object/ObjectCollection. +func (c *conn) NewData(baseType interface{}, sliceLen, bufSize int) ([]*Data, error) { + if c == nil || c.dpiConn == nil { + return nil, errors.New("connection is nil") + } + + vi, err := newVarInfo(baseType, sliceLen, bufSize) + if err != nil { + return nil, err + } + + v, dpiData, err := c.newVar(vi) + if err != nil { + return nil, err + } + defer C.dpiVar_release(v) + + data := make([]*Data, sliceLen) + for i := 0; i < sliceLen; i++ { + data[i] = &Data{dpiData: dpiData[i], NativeTypeNum: vi.NatTyp} + } + + return data, nil +} + +func newVarInfo(baseType interface{}, sliceLen, bufSize int) (varInfo, error) { + var vi varInfo + + switch v := baseType.(type) { + case Lob, []Lob: + vi.NatTyp = C.DPI_NATIVE_TYPE_LOB + var isClob bool + switch v := v.(type) { + case Lob: + isClob = v.IsClob + case []Lob: + isClob = len(v) > 0 && v[0].IsClob + } + if isClob { + vi.Typ = C.DPI_ORACLE_TYPE_CLOB + } else { + vi.Typ = C.DPI_ORACLE_TYPE_BLOB + } + case Number, []Number: + vi.Typ, vi.NatTyp = C.DPI_ORACLE_TYPE_NUMBER, C.DPI_NATIVE_TYPE_BYTES + case int, []int, int64, []int64, sql.NullInt64, []sql.NullInt64: + vi.Typ, vi.NatTyp = C.DPI_ORACLE_TYPE_NUMBER, C.DPI_NATIVE_TYPE_INT64 + case int32, []int32: + vi.Typ, vi.NatTyp = C.DPI_ORACLE_TYPE_NATIVE_INT, C.DPI_NATIVE_TYPE_INT64 + case uint, []uint, uint64, []uint64: + vi.Typ, vi.NatTyp = C.DPI_ORACLE_TYPE_NUMBER, C.DPI_NATIVE_TYPE_UINT64 + case uint32, []uint32: + vi.Typ, vi.NatTyp = C.DPI_ORACLE_TYPE_NATIVE_UINT, C.DPI_NATIVE_TYPE_UINT64 + case float32, []float32: + vi.Typ, vi.NatTyp = C.DPI_ORACLE_TYPE_NATIVE_FLOAT, C.DPI_NATIVE_TYPE_FLOAT + case float64, []float64, sql.NullFloat64, []sql.NullFloat64: + vi.Typ, vi.NatTyp = C.DPI_ORACLE_TYPE_NATIVE_DOUBLE, C.DPI_NATIVE_TYPE_DOUBLE + case bool, []bool: + vi.Typ, vi.NatTyp = C.DPI_ORACLE_TYPE_BOOLEAN, C.DPI_NATIVE_TYPE_BOOLEAN + case []byte, [][]byte: + vi.Typ, vi.NatTyp = C.DPI_ORACLE_TYPE_RAW, C.DPI_NATIVE_TYPE_BYTES + switch v := v.(type) { + case []byte: + bufSize = len(v) + case [][]byte: + for _, b := range v { + if n := len(b); n > bufSize { + bufSize = n + } + } + } + case string, []string, nil: + vi.Typ, vi.NatTyp = C.DPI_ORACLE_TYPE_VARCHAR, C.DPI_NATIVE_TYPE_BYTES + bufSize = 32767 + case time.Time, []time.Time: + vi.Typ, vi.NatTyp = C.DPI_ORACLE_TYPE_DATE, C.DPI_NATIVE_TYPE_TIMESTAMP + case userType, []userType: + vi.Typ, vi.NatTyp = C.DPI_ORACLE_TYPE_OBJECT, C.DPI_NATIVE_TYPE_OBJECT + switch v := v.(type) { + case userType: + vi.ObjectType = v.ObjectRef().ObjectType.dpiObjectType + case []userType: + if len(v) > 0 { + vi.ObjectType = v[0].ObjectRef().ObjectType.dpiObjectType + } + } + default: + return vi, errors.Errorf("unknown type %T", v) + } + + vi.IsPLSArray = reflect.TypeOf(baseType).Kind() == reflect.Slice + vi.SliceLen = sliceLen + vi.BufSize = bufSize + + return vi, nil +} + +func (d *Data) reset() { + d.NativeTypeNum = 0 + d.ObjectType = ObjectType{} + d.implicitObj = false + d.SetBytes(nil) + d.dpiData.isNull = 1 +} diff --git a/vendor/github.com/godror/godror/drv.go b/vendor/github.com/godror/godror/drv.go new file mode 100644 index 00000000000..5699088871e --- /dev/null +++ b/vendor/github.com/godror/godror/drv.go @@ -0,0 +1,963 @@ +// Copyright 2019 Tamás Gulácsi +// +// +// SPDX-License-Identifier: UPL-1.0 OR Apache-2.0 + +// Package godror is a database/sql/driver for Oracle DB. +// +// The connection string for the sql.Open("godror", connString) call can be +// the simple +// login/password@sid [AS SYSDBA|AS SYSOPER] +// +// type (with sid being the sexp returned by tnsping), +// or in the form of +// ora://login:password@sid/? \ +// sysdba=0& \ +// sysoper=0& \ +// poolMinSessions=1& \ +// poolMaxSessions=1000& \ +// poolIncrement=1& \ +// connectionClass=POOLED& \ +// standaloneConnection=0& \ +// enableEvents=0& \ +// heterogeneousPool=0& \ +// prelim=0& \ +// poolWaitTimeout=5m& \ +// poolSessionMaxLifetime=1h& \ +// poolSessionTimeout=30s& \ +// timezone=Local& \ +// newPassword= \ +// onInit=ALTER+SESSION+SET+current_schema%3Dmy_schema +// +// These are the defaults. Many advocate that a static session pool (min=max, incr=0) +// is better, with 1-10 sessions per CPU thread. +// See http://docs.oracle.com/cd/E82638_01/JJUCP/optimizing-real-world-performance.htm#JJUCP-GUID-BC09F045-5D80-4AF5-93F5-FEF0531E0E1D +// You may also use ConnectionParams to configure a connection. +// +// If you specify connectionClass, that'll reuse the same session pool +// without the connectionClass, but will specify it on each session acquire. +// Thus you can cluster the session pool with classes, or use POOLED for DRCP. +// +// For what can be used as "sid", see https://docs.oracle.com/en/database/oracle/oracle-database/19/netag/configuring-naming-methods.html#GUID-E5358DEA-D619-4B7B-A799-3D2F802500F1 +package godror + +/* +#cgo CFLAGS: -I./odpi/include -I./odpi/src -I./odpi/embed + +#include + +#include "dpi.c" +*/ +import "C" + +import ( + "context" + "database/sql" + "database/sql/driver" + "encoding/base64" + "fmt" + "hash/fnv" + "io" + "net/url" + "strconv" + "strings" + "sync" + "time" + "unsafe" + + errors "golang.org/x/xerrors" +) + +const ( + // DefaultFetchRowCount is the number of prefetched rows by default (if not changed through FetchRowCount statement option). + DefaultFetchRowCount = 1 << 8 + + // DefaultArraySize is the length of the maximum PL/SQL array by default (if not changed through ArraySize statement option). + DefaultArraySize = 1 << 10 +) + +const ( + // DpiMajorVersion is the wanted major version of the underlying ODPI-C library. + DpiMajorVersion = C.DPI_MAJOR_VERSION + // DpiMinorVersion is the wanted minor version of the underlying ODPI-C library. + DpiMinorVersion = C.DPI_MINOR_VERSION + // DpiPatchLevel is the patch level version of the underlying ODPI-C library + DpiPatchLevel = C.DPI_PATCH_LEVEL + // DpiVersionNumber is the underlying ODPI-C version as one number (Major * 10000 + Minor * 100 + Patch) + DpiVersionNumber = C.DPI_VERSION_NUMBER + + // DriverName is set on the connection to be seen in the DB + // + // It cannot be longer than 30 bytes ! + DriverName = "godror : " + Version + + // DefaultPoolMinSessions specifies the default value for minSessions for pool creation. + DefaultPoolMinSessions = 1 + // DefaultPoolMaxSessions specifies the default value for maxSessions for pool creation. + DefaultPoolMaxSessions = 1000 + // DefaultPoolIncrement specifies the default value for increment for pool creation. + DefaultPoolIncrement = 1 + // DefaultConnectionClass is the default connectionClass + DefaultConnectionClass = "GODROR" + // NoConnectionPoolingConnectionClass is a special connection class name to indicate no connection pooling. + // It is the same as setting standaloneConnection=1 + NoConnectionPoolingConnectionClass = "NO-CONNECTION-POOLING" + // DefaultSessionTimeout is the seconds before idle pool sessions get evicted + DefaultSessionTimeout = 5 * time.Minute + // DefaultWaitTimeout is the milliseconds to wait for a session to become available + DefaultWaitTimeout = 30 * time.Second + // DefaultMaxLifeTime is the maximum time in seconds till a pooled session may exist + DefaultMaxLifeTime = 1 * time.Hour +) + +// Log function. By default, it's nil, and thus logs nothing. +// If you want to change this, change it to a github.com/go-kit/kit/log.Swapper.Log +// or analog to be race-free. +var Log func(...interface{}) error + +var defaultDrv = &drv{} + +func init() { + sql.Register("godror", defaultDrv) +} + +var _ = driver.Driver((*drv)(nil)) + +type drv struct { + mu sync.Mutex + dpiContext *C.dpiContext + pools map[string]*connPool + clientVersion VersionInfo +} + +type connPool struct { + dpiPool *C.dpiPool + timeZone *time.Location + tzOffSecs int + serverVersion VersionInfo +} + +func (d *drv) init() error { + d.mu.Lock() + defer d.mu.Unlock() + if d.pools == nil { + d.pools = make(map[string]*connPool) + } + if d.dpiContext != nil { + return nil + } + var errInfo C.dpiErrorInfo + var dpiCtx *C.dpiContext + if C.dpiContext_create(C.uint(DpiMajorVersion), C.uint(DpiMinorVersion), + (**C.dpiContext)(unsafe.Pointer(&dpiCtx)), &errInfo, + ) == C.DPI_FAILURE { + return fromErrorInfo(errInfo) + } + d.dpiContext = dpiCtx + + var v C.dpiVersionInfo + if C.dpiContext_getClientVersion(d.dpiContext, &v) == C.DPI_FAILURE { + return errors.Errorf("%s: %w", "getClientVersion", d.getError()) + } + d.clientVersion.set(&v) + return nil +} + +// Open returns a new connection to the database. +// The name is a string in a driver-specific format. +func (d *drv) Open(connString string) (driver.Conn, error) { + P, err := ParseConnString(connString) + if err != nil { + return nil, err + } + + conn, err := d.openConn(P) + return conn, maybeBadConn(err, conn) +} + +func (d *drv) ClientVersion() (VersionInfo, error) { + return d.clientVersion, nil +} + +var cUTF8, cDriverName = C.CString("AL32UTF8"), C.CString(DriverName) + +func (d *drv) openConn(P ConnectionParams) (*conn, error) { + if err := d.init(); err != nil { + return nil, err + } + + P.Comb() + c := &conn{drv: d, connParams: P, timeZone: time.Local, Client: d.clientVersion} + connString := P.String() + + if Log != nil { + defer func() { + d.mu.Lock() + Log("pools", d.pools, "conn", P.String(), "drv", fmt.Sprintf("%p", d)) + d.mu.Unlock() + }() + } + + if !(P.IsSysDBA || P.IsSysOper || P.IsSysASM || P.IsPrelim || P.StandaloneConnection) { + d.mu.Lock() + dp := d.pools[connString] + d.mu.Unlock() + if dp != nil { + //Proxy authenticated connections to database will be provided by methods with context + err := dp.acquireConn(c, P) + return c, err + } + } + + extAuth := C.int(b2i(P.Username == "" && P.Password == "")) + var cUserName, cPassword, cNewPassword, cConnClass *C.char + if !(P.Username == "" && P.Password == "") { + cUserName, cPassword = C.CString(P.Username), C.CString(P.Password) + } + var cSid *C.char + if P.SID != "" { + cSid = C.CString(P.SID) + } + defer func() { + if cUserName != nil { + C.free(unsafe.Pointer(cUserName)) + C.free(unsafe.Pointer(cPassword)) + } + if cNewPassword != nil { + C.free(unsafe.Pointer(cNewPassword)) + } + if cSid != nil { + C.free(unsafe.Pointer(cSid)) + } + if cConnClass != nil { + C.free(unsafe.Pointer(cConnClass)) + } + }() + var commonCreateParams C.dpiCommonCreateParams + if C.dpiContext_initCommonCreateParams(d.dpiContext, &commonCreateParams) == C.DPI_FAILURE { + return nil, errors.Errorf("initCommonCreateParams: %w", d.getError()) + } + commonCreateParams.createMode = C.DPI_MODE_CREATE_DEFAULT | C.DPI_MODE_CREATE_THREADED + if P.EnableEvents { + commonCreateParams.createMode |= C.DPI_MODE_CREATE_EVENTS + } + commonCreateParams.encoding = cUTF8 + commonCreateParams.nencoding = cUTF8 + commonCreateParams.driverName = cDriverName + commonCreateParams.driverNameLength = C.uint32_t(len(DriverName)) + + if P.IsSysDBA || P.IsSysOper || P.IsSysASM || P.IsPrelim || P.StandaloneConnection { + // no pool + c.connParams = P + return c, c.acquireConn(P.Username, P.Password, P.ConnClass) + } + var poolCreateParams C.dpiPoolCreateParams + if C.dpiContext_initPoolCreateParams(d.dpiContext, &poolCreateParams) == C.DPI_FAILURE { + return nil, errors.Errorf("initPoolCreateParams: %w", d.getError()) + } + poolCreateParams.minSessions = DefaultPoolMinSessions + if P.MinSessions >= 0 { + poolCreateParams.minSessions = C.uint32_t(P.MinSessions) + } + poolCreateParams.maxSessions = DefaultPoolMaxSessions + if P.MaxSessions > 0 { + poolCreateParams.maxSessions = C.uint32_t(P.MaxSessions) + } + poolCreateParams.sessionIncrement = DefaultPoolIncrement + if P.PoolIncrement > 0 { + poolCreateParams.sessionIncrement = C.uint32_t(P.PoolIncrement) + } + if extAuth == 1 || P.HeterogeneousPool { + poolCreateParams.homogeneous = 0 + } + poolCreateParams.externalAuth = extAuth + poolCreateParams.getMode = C.DPI_MODE_POOL_GET_TIMEDWAIT + poolCreateParams.timeout = C.uint32_t(DefaultSessionTimeout / time.Second) + if P.SessionTimeout > time.Second { + poolCreateParams.timeout = C.uint32_t(P.SessionTimeout / time.Second) // seconds before idle pool sessions get evicted + } + poolCreateParams.waitTimeout = C.uint32_t(DefaultWaitTimeout / time.Millisecond) + if P.WaitTimeout > time.Millisecond { + poolCreateParams.waitTimeout = C.uint32_t(P.WaitTimeout / time.Millisecond) // milliseconds to wait for a session to become available + } + poolCreateParams.maxLifetimeSession = C.uint32_t(DefaultMaxLifeTime / time.Second) + if P.MaxLifeTime > 0 { + poolCreateParams.maxLifetimeSession = C.uint32_t(P.MaxLifeTime / time.Second) // maximum time in seconds till a pooled session may exist + } + + var dp *C.dpiPool + if Log != nil { + Log("C", "dpiPool_create", "username", P.Username, "conn", connString, "sid", P.SID, "common", commonCreateParams, "pool", fmt.Sprintf("%#v", poolCreateParams)) + } + if C.dpiPool_create( + d.dpiContext, + cUserName, C.uint32_t(len(P.Username)), + cPassword, C.uint32_t(len(P.Password)), + cSid, C.uint32_t(len(P.SID)), + &commonCreateParams, + &poolCreateParams, + (**C.dpiPool)(unsafe.Pointer(&dp)), + ) == C.DPI_FAILURE { + return nil, errors.Errorf("params=%s extAuth=%v: %w", P.String(), extAuth, d.getError()) + } + C.dpiPool_setStmtCacheSize(dp, 40) + pool := &connPool{dpiPool: dp} + d.mu.Lock() + d.pools[connString] = pool + d.mu.Unlock() + + return c, pool.acquireConn(c, P) +} + +func (dp *connPool) acquireConn(c *conn, P ConnectionParams) error { + P.Comb() + c.mu.Lock() + c.connParams = P + c.Client, c.Server = c.drv.clientVersion, dp.serverVersion + c.timeZone, c.tzOffSecs = dp.timeZone, dp.tzOffSecs + c.mu.Unlock() + + var connCreateParams C.dpiConnCreateParams + if C.dpiContext_initConnCreateParams(c.drv.dpiContext, &connCreateParams) == C.DPI_FAILURE { + return errors.Errorf("initConnCreateParams: %w", c.drv.getError()) + } + if P.ConnClass != "" { + cConnClass := C.CString(P.ConnClass) + defer C.free(unsafe.Pointer(cConnClass)) + connCreateParams.connectionClass = cConnClass + connCreateParams.connectionClassLength = C.uint32_t(len(P.ConnClass)) + } + dc := C.malloc(C.sizeof_void) + if C.dpiPool_acquireConnection( + dp.dpiPool, + nil, 0, nil, 0, + &connCreateParams, + (**C.dpiConn)(unsafe.Pointer(&dc)), + ) == C.DPI_FAILURE { + C.free(unsafe.Pointer(dc)) + return errors.Errorf("acquirePoolConnection(user=%q, params=%#v): %w", P.Username, connCreateParams, c.getError()) + } + + c.mu.Lock() + c.dpiConn = (*C.dpiConn)(dc) + c.currentUser = P.Username + c.newSession = connCreateParams.outNewSession == 1 + c.mu.Unlock() + err := c.init(P.OnInit) + if err == nil { + c.mu.Lock() + dp.serverVersion = c.Server + dp.timeZone, dp.tzOffSecs = c.timeZone, c.tzOffSecs + c.mu.Unlock() + } + + return err +} + +func (c *conn) acquireConn(user, pass, connClass string) error { + P := c.connParams + if !(P.IsSysDBA || P.IsSysOper || P.IsSysASM || P.IsPrelim || P.StandaloneConnection) { + c.drv.mu.Lock() + pool := c.drv.pools[P.String()] + if Log != nil { + Log("pools", c.drv.pools, "drv", fmt.Sprintf("%p", c.drv)) + } + c.drv.mu.Unlock() + if pool != nil { + P.Username, P.Password, P.ConnClass = user, pass, connClass + return pool.acquireConn(c, P) + } + } + + var connCreateParams C.dpiConnCreateParams + if C.dpiContext_initConnCreateParams(c.drv.dpiContext, &connCreateParams) == C.DPI_FAILURE { + return errors.Errorf("initConnCreateParams: %w", c.drv.getError()) + } + var cUserName, cPassword, cNewPassword, cConnClass, cSid *C.char + defer func() { + if cUserName != nil { + C.free(unsafe.Pointer(cUserName)) + } + if cPassword != nil { + C.free(unsafe.Pointer(cPassword)) + } + if cNewPassword != nil { + C.free(unsafe.Pointer(cNewPassword)) + } + if cConnClass != nil { + C.free(unsafe.Pointer(cConnClass)) + } + if cSid != nil { + C.free(unsafe.Pointer(cSid)) + } + }() + if user != "" { + cUserName = C.CString(user) + } + if pass != "" { + cPassword = C.CString(pass) + } + if connClass != "" { + cConnClass = C.CString(connClass) + connCreateParams.connectionClass = cConnClass + connCreateParams.connectionClassLength = C.uint32_t(len(connClass)) + } + var commonCreateParams C.dpiCommonCreateParams + if C.dpiContext_initCommonCreateParams(c.drv.dpiContext, &commonCreateParams) == C.DPI_FAILURE { + return errors.Errorf("initCommonCreateParams: %w", c.drv.getError()) + } + commonCreateParams.createMode = C.DPI_MODE_CREATE_DEFAULT | C.DPI_MODE_CREATE_THREADED + if P.EnableEvents { + commonCreateParams.createMode |= C.DPI_MODE_CREATE_EVENTS + } + commonCreateParams.encoding = cUTF8 + commonCreateParams.nencoding = cUTF8 + commonCreateParams.driverName = cDriverName + commonCreateParams.driverNameLength = C.uint32_t(len(DriverName)) + + if P.SID != "" { + cSid = C.CString(P.SID) + } + connCreateParams.authMode = P.authMode() + extAuth := C.int(b2i(user == "" && pass == "")) + connCreateParams.externalAuth = extAuth + if P.NewPassword != "" { + cNewPassword = C.CString(P.NewPassword) + connCreateParams.newPassword = cNewPassword + connCreateParams.newPasswordLength = C.uint32_t(len(P.NewPassword)) + } + if Log != nil { + Log("C", "dpiConn_create", "params", P.String(), "common", commonCreateParams, "conn", connCreateParams) + } + dc := C.malloc(C.sizeof_void) + if C.dpiConn_create( + c.drv.dpiContext, + cUserName, C.uint32_t(len(user)), + cPassword, C.uint32_t(len(pass)), + cSid, C.uint32_t(len(P.SID)), + &commonCreateParams, + &connCreateParams, + (**C.dpiConn)(unsafe.Pointer(&dc)), + ) == C.DPI_FAILURE { + C.free(unsafe.Pointer(dc)) + return errors.Errorf("username=%q sid=%q params=%+v: %w", user, P.SID, connCreateParams, c.drv.getError()) + } + c.mu.Lock() + c.dpiConn = (*C.dpiConn)(dc) + c.currentUser = user + c.newSession = true + P.Username, P.Password, P.ConnClass = user, pass, connClass + if P.NewPassword != "" { + P.Password, P.NewPassword = P.NewPassword, "" + } + c.connParams = P + c.mu.Unlock() + return c.init(P.OnInit) +} + +// ConnectionParams holds the params for a connection (pool). +// You can use ConnectionParams{...}.StringWithPassword() +// as a connection string in sql.Open. +type ConnectionParams struct { + OnInit []string + Username, Password, SID, ConnClass string + // NewPassword is used iff StandaloneConnection is true! + NewPassword string + MinSessions, MaxSessions, PoolIncrement int + WaitTimeout, MaxLifeTime, SessionTimeout time.Duration + Timezone *time.Location + IsSysDBA, IsSysOper, IsSysASM, IsPrelim bool + HeterogeneousPool bool + StandaloneConnection bool + EnableEvents bool +} + +// String returns the string representation of ConnectionParams. +// The password is replaced with a "SECRET" string! +func (P ConnectionParams) String() string { + return P.string(true, false) +} + +// StringNoClass returns the string representation of ConnectionParams, without class info. +// The password is replaced with a "SECRET" string! +func (P ConnectionParams) StringNoClass() string { + return P.string(false, false) +} + +// StringWithPassword returns the string representation of ConnectionParams (as String() does), +// but does NOT obfuscate the password, just prints it as is. +func (P ConnectionParams) StringWithPassword() string { + return P.string(true, true) +} + +func (P ConnectionParams) string(class, withPassword bool) string { + host, path := P.SID, "" + if i := strings.IndexByte(host, '/'); i >= 0 { + host, path = host[:i], host[i:] + } + q := make(url.Values, 32) + s := P.ConnClass + if !class { + s = "" + } + q.Add("connectionClass", s) + + password := P.Password + if withPassword { + q.Add("newPassword", P.NewPassword) + } else { + hsh := fnv.New64() + io.WriteString(hsh, P.Password) + password = "SECRET-" + base64.URLEncoding.EncodeToString(hsh.Sum(nil)) + if P.NewPassword != "" { + hsh.Reset() + io.WriteString(hsh, P.NewPassword) + q.Add("newPassword", "SECRET-"+base64.URLEncoding.EncodeToString(hsh.Sum(nil))) + } + } + s = "" + if P.Timezone != nil { + s = P.Timezone.String() + } + q.Add("timezone", s) + B := func(b bool) string { + if b { + return "1" + } + return "0" + } + q.Add("poolMinSessions", strconv.Itoa(P.MinSessions)) + q.Add("poolMaxSessions", strconv.Itoa(P.MaxSessions)) + q.Add("poolIncrement", strconv.Itoa(P.PoolIncrement)) + q.Add("sysdba", B(P.IsSysDBA)) + q.Add("sysoper", B(P.IsSysOper)) + q.Add("sysasm", B(P.IsSysASM)) + q.Add("standaloneConnection", B(P.StandaloneConnection)) + q.Add("enableEvents", B(P.EnableEvents)) + q.Add("heterogeneousPool", B(P.HeterogeneousPool)) + q.Add("prelim", B(P.IsPrelim)) + q.Add("poolWaitTimeout", P.WaitTimeout.String()) + q.Add("poolSessionMaxLifetime", P.MaxLifeTime.String()) + q.Add("poolSessionTimeout", P.SessionTimeout.String()) + q["onInit"] = P.OnInit + return (&url.URL{ + Scheme: "oracle", + User: url.UserPassword(P.Username, password), + Host: host, + Path: path, + RawQuery: q.Encode(), + }).String() +} + +func (P *ConnectionParams) Comb() { + P.StandaloneConnection = P.StandaloneConnection || P.ConnClass == NoConnectionPoolingConnectionClass + if P.IsPrelim || P.StandaloneConnection { + // Prelim: the shared memory may not exist when Oracle is shut down. + P.ConnClass = "" + P.HeterogeneousPool = false + } +} + +// ParseConnString parses the given connection string into a struct. +func ParseConnString(connString string) (ConnectionParams, error) { + P := ConnectionParams{ + MinSessions: DefaultPoolMinSessions, + MaxSessions: DefaultPoolMaxSessions, + PoolIncrement: DefaultPoolIncrement, + ConnClass: DefaultConnectionClass, + MaxLifeTime: DefaultMaxLifeTime, + WaitTimeout: DefaultWaitTimeout, + SessionTimeout: DefaultSessionTimeout, + } + if !strings.HasPrefix(connString, "oracle://") { + i := strings.IndexByte(connString, '/') + if i < 0 { + return P, errors.New("no '/' in connection string") + } + P.Username, connString = connString[:i], connString[i+1:] + + uSid := strings.ToUpper(connString) + //fmt.Printf("connString=%q SID=%q\n", connString, uSid) + if strings.Contains(uSid, " AS ") { + if P.IsSysDBA = strings.HasSuffix(uSid, " AS SYSDBA"); P.IsSysDBA { + connString = connString[:len(connString)-10] + } else if P.IsSysOper = strings.HasSuffix(uSid, " AS SYSOPER"); P.IsSysOper { + connString = connString[:len(connString)-11] + } else if P.IsSysASM = strings.HasSuffix(uSid, " AS SYSASM"); P.IsSysASM { + connString = connString[:len(connString)-10] + } + } + if i = strings.IndexByte(connString, '@'); i >= 0 { + P.Password, P.SID = connString[:i], connString[i+1:] + } else { + P.Password = connString + } + if strings.HasSuffix(P.SID, ":POOLED") { + P.ConnClass, P.SID = "POOLED", P.SID[:len(P.SID)-7] + } + //fmt.Printf("connString=%q params=%s\n", connString, P) + return P, nil + } + u, err := url.Parse(connString) + if err != nil { + return P, errors.Errorf("%s: %w", connString, err) + } + if usr := u.User; usr != nil { + P.Username = usr.Username() + P.Password, _ = usr.Password() + } + P.SID = u.Hostname() + // IPv6 literal address brackets are removed by u.Hostname, + // so we have to put them back + if strings.HasPrefix(u.Host, "[") && !strings.Contains(P.SID[1:], "]") { + P.SID = "[" + P.SID + "]" + } + if u.Port() != "" { + P.SID += ":" + u.Port() + } + if u.Path != "" && u.Path != "/" { + P.SID += u.Path + } + q := u.Query() + if vv, ok := q["connectionClass"]; ok { + P.ConnClass = vv[0] + } + for _, task := range []struct { + Dest *bool + Key string + }{ + {&P.IsSysDBA, "sysdba"}, + {&P.IsSysOper, "sysoper"}, + {&P.IsSysASM, "sysasm"}, + {&P.IsPrelim, "prelim"}, + + {&P.StandaloneConnection, "standaloneConnection"}, + {&P.EnableEvents, "enableEvents"}, + {&P.HeterogeneousPool, "heterogeneousPool"}, + } { + *task.Dest = q.Get(task.Key) == "1" + } + if tz := q.Get("timezone"); tz != "" { + if tz == "local" { + P.Timezone = time.Local + } else if strings.Contains(tz, "/") { + if P.Timezone, err = time.LoadLocation(tz); err != nil { + return P, errors.Errorf("%s: %w", tz, err) + } + } else if off, err := parseTZ(tz); err == nil { + P.Timezone = time.FixedZone(tz, off) + } else { + return P, errors.Errorf("%s: %w", tz, err) + } + } + + for _, task := range []struct { + Dest *int + Key string + }{ + {&P.MinSessions, "poolMinSessions"}, + {&P.MaxSessions, "poolMaxSessions"}, + {&P.PoolIncrement, "poolIncrement"}, + } { + s := q.Get(task.Key) + if s == "" { + continue + } + var err error + *task.Dest, err = strconv.Atoi(s) + if err != nil { + return P, errors.Errorf("%s: %w", task.Key+"="+s, err) + } + } + for _, task := range []struct { + Dest *time.Duration + Key string + }{ + {&P.SessionTimeout, "poolSessionTimeout"}, + {&P.WaitTimeout, "poolWaitTimeout"}, + {&P.MaxLifeTime, "poolSessionMaxLifetime"}, + } { + s := q.Get(task.Key) + if s == "" { + continue + } + var err error + *task.Dest, err = time.ParseDuration(s) + if err != nil { + if !strings.Contains(err.Error(), "time: missing unit in duration") { + return P, errors.Errorf("%s: %w", task.Key+"="+s, err) + } + i, err := strconv.Atoi(s) + if err != nil { + return P, errors.Errorf("%s: %w", task.Key+"="+s, err) + } + base := time.Second + if task.Key == "poolWaitTimeout" { + base = time.Millisecond + } + *task.Dest = time.Duration(i) * base + } + } + if P.MinSessions > P.MaxSessions { + P.MinSessions = P.MaxSessions + } + if P.MinSessions == P.MaxSessions { + P.PoolIncrement = 0 + } else if P.PoolIncrement < 1 { + P.PoolIncrement = 1 + } + P.OnInit = q["onInit"] + + P.Comb() + if P.StandaloneConnection { + P.NewPassword = q.Get("newPassword") + } + + return P, nil +} + +// SetSessionParamOnInit adds an "ALTER SESSION k=v" to the OnInit task list. +func (P *ConnectionParams) SetSessionParamOnInit(k, v string) { + P.OnInit = append(P.OnInit, fmt.Sprintf("ALTER SESSION SET %s = q'(%s)'", k, strings.Replace(v, "'", "''", -1))) +} + +func (P ConnectionParams) authMode() C.dpiAuthMode { + authMode := C.dpiAuthMode(C.DPI_MODE_AUTH_DEFAULT) + // OR all the modes together + for _, elt := range []struct { + Is bool + Mode C.dpiAuthMode + }{ + {P.IsSysDBA, C.DPI_MODE_AUTH_SYSDBA}, + {P.IsSysOper, C.DPI_MODE_AUTH_SYSOPER}, + {P.IsSysASM, C.DPI_MODE_AUTH_SYSASM}, + {P.IsPrelim, C.DPI_MODE_AUTH_PRELIM}, + } { + if elt.Is { + authMode |= elt.Mode + } + } + return authMode +} + +// OraErr is an error holding the ORA-01234 code and the message. +type OraErr struct { + message string + code int +} + +// AsOraErr returns the underlying *OraErr and whether it succeeded. +func AsOraErr(err error) (*OraErr, bool) { + var oerr *OraErr + ok := errors.As(err, &oerr) + return oerr, ok +} + +var _ = error((*OraErr)(nil)) + +// Code returns the OraErr's error code. +func (oe *OraErr) Code() int { return oe.code } + +// Message returns the OraErr's message. +func (oe *OraErr) Message() string { return oe.message } +func (oe *OraErr) Error() string { + msg := oe.Message() + if oe.code == 0 && msg == "" { + return "" + } + return fmt.Sprintf("ORA-%05d: %s", oe.code, oe.message) +} +func fromErrorInfo(errInfo C.dpiErrorInfo) *OraErr { + oe := OraErr{ + code: int(errInfo.code), + message: strings.TrimSpace(C.GoString(errInfo.message)), + } + if oe.code == 0 && strings.HasPrefix(oe.message, "ORA-") && + len(oe.message) > 9 && oe.message[9] == ':' { + if i, _ := strconv.Atoi(oe.message[4:9]); i > 0 { + oe.code = i + } + } + oe.message = strings.TrimPrefix(oe.message, fmt.Sprintf("ORA-%05d: ", oe.Code())) + return &oe +} + +// newErrorInfo is just for testing: testing cannot use Cgo... +func newErrorInfo(code int, message string) C.dpiErrorInfo { + return C.dpiErrorInfo{code: C.int32_t(code), message: C.CString(message)} +} + +// against deadcode +var _ = newErrorInfo + +func (d *drv) getError() *OraErr { + if d == nil || d.dpiContext == nil { + return &OraErr{code: -12153, message: driver.ErrBadConn.Error()} + } + var errInfo C.dpiErrorInfo + C.dpiContext_getError(d.dpiContext, &errInfo) + return fromErrorInfo(errInfo) +} + +func b2i(b bool) uint8 { + if b { + return 1 + } + return 0 +} + +// VersionInfo holds version info returned by Oracle DB. +type VersionInfo struct { + ServerRelease string + Version, Release, Update, PortRelease, PortUpdate, Full uint8 +} + +func (V *VersionInfo) set(v *C.dpiVersionInfo) { + *V = VersionInfo{ + Version: uint8(v.versionNum), + Release: uint8(v.releaseNum), Update: uint8(v.updateNum), + PortRelease: uint8(v.portReleaseNum), PortUpdate: uint8(v.portUpdateNum), + Full: uint8(v.fullVersionNum), + } +} +func (V VersionInfo) String() string { + var s string + if V.ServerRelease != "" { + s = " [" + V.ServerRelease + "]" + } + return fmt.Sprintf("%d.%d.%d.%d.%d%s", V.Version, V.Release, V.Update, V.PortRelease, V.PortUpdate, s) +} + +var timezones = make(map[[2]C.int8_t]*time.Location) +var timezonesMu sync.RWMutex + +func timeZoneFor(hourOffset, minuteOffset C.int8_t) *time.Location { + if hourOffset == 0 && minuteOffset == 0 { + return time.UTC + } + key := [2]C.int8_t{hourOffset, minuteOffset} + timezonesMu.RLock() + tz := timezones[key] + timezonesMu.RUnlock() + if tz == nil { + timezonesMu.Lock() + if tz = timezones[key]; tz == nil { + tz = time.FixedZone( + fmt.Sprintf("%02d:%02d", hourOffset, minuteOffset), + int(hourOffset)*3600+int(minuteOffset)*60, + ) + timezones[key] = tz + } + timezonesMu.Unlock() + } + return tz +} + +type ctxKey string + +const logCtxKey = ctxKey("godror.Log") + +type logFunc func(...interface{}) error + +func ctxGetLog(ctx context.Context) logFunc { + if lgr, ok := ctx.Value(logCtxKey).(func(...interface{}) error); ok { + return lgr + } + return Log +} + +// ContextWithLog returns a context with the given log function. +func ContextWithLog(ctx context.Context, logF func(...interface{}) error) context.Context { + return context.WithValue(ctx, logCtxKey, logF) +} + +var _ = driver.DriverContext((*drv)(nil)) +var _ = driver.Connector((*connector)(nil)) + +type connector struct { + drv *drv + onInit func(driver.Conn) error + ConnectionParams +} + +// OpenConnector must parse the name in the same format that Driver.Open +// parses the name parameter. +func (d *drv) OpenConnector(name string) (driver.Connector, error) { + P, err := ParseConnString(name) + if err != nil { + return nil, err + } + + return connector{ConnectionParams: P, drv: d}, nil +} + +// Connect returns a connection to the database. +// Connect may return a cached connection (one previously +// closed), but doing so is unnecessary; the sql package +// maintains a pool of idle connections for efficient re-use. +// +// The provided context.Context is for dialing purposes only +// (see net.DialContext) and should not be stored or used for +// other purposes. +// +// The returned connection is only used by one goroutine at a +// time. +func (c connector) Connect(context.Context) (driver.Conn, error) { + conn, err := c.drv.openConn(c.ConnectionParams) + if err != nil || c.onInit == nil || !conn.newSession { + return conn, err + } + if err = c.onInit(conn); err != nil { + conn.close(true) + return nil, err + } + return conn, nil +} + +// Driver returns the underlying Driver of the Connector, +// mainly to maintain compatibility with the Driver method +// on sql.DB. +func (c connector) Driver() driver.Driver { return c.drv } + +// NewConnector returns a driver.Connector to be used with sql.OpenDB, +// which calls the given onInit if the connection is new. +// +// For an onInit example, see NewSessionIniter. +func (d *drv) NewConnector(name string, onInit func(driver.Conn) error) (driver.Connector, error) { + cxr, err := d.OpenConnector(name) + if err != nil { + return nil, err + } + cx := cxr.(connector) + cx.onInit = onInit + return cx, err +} + +// NewConnector returns a driver.Connector to be used with sql.OpenDB, +// (for the default Driver registered with godror) +// which calls the given onInit if the connection is new. +// +// For an onInit example, see NewSessionIniter. +func NewConnector(name string, onInit func(driver.Conn) error) (driver.Connector, error) { + return defaultDrv.NewConnector(name, onInit) +} + +// NewSessionIniter returns a function suitable for use in NewConnector as onInit, +// which calls "ALTER SESSION SET =''" for each element of the given map. +func NewSessionIniter(m map[string]string) func(driver.Conn) error { + return func(cx driver.Conn) error { + for k, v := range m { + qry := fmt.Sprintf("ALTER SESSION SET %s = q'(%s)'", k, strings.Replace(v, "'", "''", -1)) + st, err := cx.Prepare(qry) + if err != nil { + return errors.Errorf("%s: %w", qry, err) + } + _, err = st.Exec(nil) //lint:ignore SA1019 it's hard to use ExecContext here + st.Close() + if err != nil { + return err + } + } + return nil + } +} diff --git a/vendor/github.com/godror/godror/drv_posix.go b/vendor/github.com/godror/godror/drv_posix.go new file mode 100644 index 00000000000..c88fa6ec60c --- /dev/null +++ b/vendor/github.com/godror/godror/drv_posix.go @@ -0,0 +1,11 @@ +// +build !windows + +// Copyright 2017 Tamás Gulácsi +// +// +// SPDX-License-Identifier: UPL-1.0 OR Apache-2.0 + +package godror + +// #cgo LDFLAGS: -ldl -lpthread +import "C" diff --git a/vendor/github.com/godror/godror/go.mod b/vendor/github.com/godror/godror/go.mod new file mode 100644 index 00000000000..86f145abad2 --- /dev/null +++ b/vendor/github.com/godror/godror/go.mod @@ -0,0 +1,12 @@ +module github.com/godror/godror + +go 1.12 + +require ( + github.com/go-kit/kit v0.9.0 + github.com/go-logfmt/logfmt v0.4.0 + github.com/go-stack/stack v1.8.0 // indirect + github.com/google/go-cmp v0.3.1 + golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e + golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 +) diff --git a/vendor/github.com/godror/godror/go.sum b/vendor/github.com/godror/godror/go.sum new file mode 100644 index 00000000000..2456fcd618c --- /dev/null +++ b/vendor/github.com/godror/godror/go.sum @@ -0,0 +1,14 @@ +github.com/go-kit/kit v0.9.0 h1:wDJmvq38kDhkVxi50ni9ykkdUr1PKgqKOoi01fa0Mdk= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.4.0 h1:MP4Eh7ZCb31lleYCFuwm0oe4/YGak+5l1vA2NOE80nA= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/vendor/gopkg.in/goracle.v2/lob.go b/vendor/github.com/godror/godror/lob.go similarity index 77% rename from vendor/gopkg.in/goracle.v2/lob.go rename to vendor/github.com/godror/godror/lob.go index 567dbaa843d..a914462d464 100644 --- a/vendor/gopkg.in/goracle.v2/lob.go +++ b/vendor/github.com/godror/godror/lob.go @@ -1,19 +1,9 @@ // Copyright 2017 Tamás Gulácsi // // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-License-Identifier: UPL-1.0 OR Apache-2.0 -package goracle +package godror /* #include "dpiImpl.h" @@ -25,7 +15,7 @@ import ( "unicode/utf8" "unsafe" - "github.com/pkg/errors" + errors "golang.org/x/xerrors" ) // Lob is for reading/writing a LOB. @@ -98,7 +88,9 @@ func (dlr *dpiLobReader) Read(p []byte) (int, error) { if dlr.sizePlusOne == 0 { // never read size before if C.dpiLob_getSize(dlr.dpiLob, &dlr.sizePlusOne) == C.DPI_FAILURE { - return 0, errors.Wrap(dlr.getError(), "getSize") + C.dpiLob_close(dlr.dpiLob) + dlr.dpiLob = nil + return 0, errors.Errorf("getSize: %w", dlr.getError()) } dlr.sizePlusOne++ } @@ -108,12 +100,14 @@ func (dlr *dpiLobReader) Read(p []byte) (int, error) { return 0, io.EOF } if C.dpiLob_readBytes(dlr.dpiLob, dlr.offset+1, n, (*C.char)(unsafe.Pointer(&p[0])), &n) == C.DPI_FAILURE { + C.dpiLob_close(dlr.dpiLob) + dlr.dpiLob = nil err := dlr.getError() if dlr.finished = err.(interface{ Code() int }).Code() == 1403; dlr.finished { dlr.offset += n return int(n), io.EOF } - return int(n), errors.Wrapf(err, "lob=%p offset=%d n=%d", dlr.dpiLob, dlr.offset, len(p)) + return int(n), errors.Errorf("lob=%p offset=%d n=%d: %w", dlr.dpiLob, dlr.offset, len(p), err) } //fmt.Printf("read %d\n", n) if dlr.IsClob { @@ -123,6 +117,9 @@ func (dlr *dpiLobReader) Read(p []byte) (int, error) { } var err error if n == 0 || dlr.offset+1 >= dlr.sizePlusOne { + C.dpiLob_close(dlr.dpiLob) + dlr.dpiLob = nil + dlr.finished = true err = io.EOF } return int(n), err @@ -141,14 +138,14 @@ func (dlw *dpiLobWriter) Write(p []byte) (int, error) { if !dlw.opened { //fmt.Printf("open %p\n", lob) if C.dpiLob_openResource(lob) == C.DPI_FAILURE { - return 0, errors.Wrapf(dlw.getError(), "openResources(%p)", lob) + return 0, errors.Errorf("openResources(%p): %w", lob, dlw.getError()) } dlw.opened = true } n := C.uint64_t(len(p)) if C.dpiLob_writeBytes(lob, dlw.offset+1, (*C.char)(unsafe.Pointer(&p[0])), n) == C.DPI_FAILURE { - err := errors.Wrapf(dlw.getError(), "writeBytes(%p, offset=%d, data=%d)", lob, dlw.offset, n) + err := errors.Errorf("writeBytes(%p, offset=%d, data=%d): %w", lob, dlw.offset, n, dlw.getError()) dlw.dpiLob = nil C.dpiLob_closeResource(lob) return 0, err @@ -171,7 +168,7 @@ func (dlw *dpiLobWriter) Close() error { if ec, ok := err.(interface{ Code() int }); ok && !dlw.opened && ec.Code() == 22289 { // cannot perform %s operation on an unopened file or LOB return nil } - return errors.Wrapf(err, "closeResource(%p)", lob) + return errors.Errorf("closeResource(%p): %w", lob, err) } return nil } @@ -186,6 +183,19 @@ type DirectLob struct { var _ = io.ReaderAt((*DirectLob)(nil)) var _ = io.WriterAt((*DirectLob)(nil)) +// NewTempLob returns a temporary LOB as DirectLob. +func (c *conn) NewTempLob(isClob bool) (*DirectLob, error) { + typ := C.uint(C.DPI_ORACLE_TYPE_BLOB) + if isClob { + typ = C.DPI_ORACLE_TYPE_CLOB + } + lob := DirectLob{conn: c} + if C.dpiConn_newTempLob(c.dpiConn, typ, &lob.dpiLob) == C.DPI_FAILURE { + return nil, errors.Errorf("newTempLob: %w", c.getError()) + } + return &lob, nil +} + // Close the Lob. func (dl *DirectLob) Close() error { if !dl.opened { @@ -193,7 +203,7 @@ func (dl *DirectLob) Close() error { } dl.opened = false if C.dpiLob_closeResource(dl.dpiLob) == C.DPI_FAILURE { - return errors.Wrap(dl.conn.getError(), "closeResource") + return errors.Errorf("closeResource: %w", dl.conn.getError()) } return nil } @@ -202,7 +212,7 @@ func (dl *DirectLob) Close() error { func (dl *DirectLob) Size() (int64, error) { var n C.uint64_t if C.dpiLob_getSize(dl.dpiLob, &n) == C.DPI_FAILURE { - return int64(n), errors.Wrap(dl.conn.getError(), "getSize") + return int64(n), errors.Errorf("getSize: %w", dl.conn.getError()) } return int64(n), nil } @@ -210,7 +220,7 @@ func (dl *DirectLob) Size() (int64, error) { // Trim the LOB to the given size. func (dl *DirectLob) Trim(size int64) error { if C.dpiLob_trim(dl.dpiLob, C.uint64_t(size)) == C.DPI_FAILURE { - return errors.Wrap(dl.conn.getError(), "trim") + return errors.Errorf("trim: %w", dl.conn.getError()) } return nil } @@ -219,7 +229,7 @@ func (dl *DirectLob) Trim(size int64) error { // The LOB is cleared first. func (dl *DirectLob) Set(p []byte) error { if C.dpiLob_setFromBytes(dl.dpiLob, (*C.char)(unsafe.Pointer(&p[0])), C.uint64_t(len(p))) == C.DPI_FAILURE { - return errors.Wrap(dl.conn.getError(), "setFromBytes") + return errors.Errorf("setFromBytes: %w", dl.conn.getError()) } return nil } @@ -228,7 +238,7 @@ func (dl *DirectLob) Set(p []byte) error { func (dl *DirectLob) ReadAt(p []byte, offset int64) (int, error) { n := C.uint64_t(len(p)) if C.dpiLob_readBytes(dl.dpiLob, C.uint64_t(offset)+1, n, (*C.char)(unsafe.Pointer(&p[0])), &n) == C.DPI_FAILURE { - return int(n), errors.Wrap(dl.conn.getError(), "readBytes") + return int(n), errors.Errorf("readBytes: %w", dl.conn.getError()) } return int(n), nil } @@ -238,14 +248,14 @@ func (dl *DirectLob) WriteAt(p []byte, offset int64) (int, error) { if !dl.opened { //fmt.Printf("open %p\n", lob) if C.dpiLob_openResource(dl.dpiLob) == C.DPI_FAILURE { - return 0, errors.Wrapf(dl.conn.getError(), "openResources(%p)", dl.dpiLob) + return 0, errors.Errorf("openResources(%p): %w", dl.dpiLob, dl.conn.getError()) } dl.opened = true } n := C.uint64_t(len(p)) if C.dpiLob_writeBytes(dl.dpiLob, C.uint64_t(offset)+1, (*C.char)(unsafe.Pointer(&p[0])), n) == C.DPI_FAILURE { - return int(n), errors.Wrap(dl.conn.getError(), "writeBytes") + return int(n), errors.Errorf("writeBytes: %w", dl.conn.getError()) } return int(n), nil } diff --git a/vendor/gopkg.in/goracle.v2/obj.go b/vendor/github.com/godror/godror/obj.go similarity index 53% rename from vendor/gopkg.in/goracle.v2/obj.go rename to vendor/github.com/godror/godror/obj.go index e8f97afcfd9..17d03d732fa 100644 --- a/vendor/gopkg.in/goracle.v2/obj.go +++ b/vendor/github.com/godror/godror/obj.go @@ -1,19 +1,9 @@ // Copyright 2017 Tamás Gulácsi // // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-License-Identifier: UPL-1.0 OR Apache-2.0 -package goracle +package godror /* #include @@ -21,23 +11,25 @@ package goracle */ import "C" import ( + "context" "fmt" "reflect" + "strings" + "sync" "unsafe" - "github.com/pkg/errors" + errors "golang.org/x/xerrors" ) var _ = fmt.Printf // Object represents a dpiObject. type Object struct { - scratch Data - ObjectType dpiObject *C.dpiObject + ObjectType } -func (O *Object) getError() error { return O.drv.getError() } +func (O *Object) getError() error { return O.conn.getError() } // ErrNoSuchKey is the error for missing key in lookup. var ErrNoSuchKey = errors.New("no such key") @@ -49,45 +41,58 @@ func (O *Object) GetAttribute(data *Data, name string) error { } attr, ok := O.Attributes[name] if !ok { - return errors.Wrap(ErrNoSuchKey, name) + return errors.Errorf("%s: %w", name, ErrNoSuchKey) } data.reset() data.NativeTypeNum = attr.NativeTypeNum data.ObjectType = attr.ObjectType - wasNull := data.dpiData == nil + data.implicitObj = true // the maximum length of that buffer must be supplied // in the value.asBytes.length attribute before calling this function. if attr.NativeTypeNum == C.DPI_NATIVE_TYPE_BYTES && attr.OracleTypeNum == C.DPI_ORACLE_TYPE_NUMBER { - var a [22]byte - C.dpiData_setBytes(data.dpiData, (*C.char)(unsafe.Pointer(&a[0])), 22) + var a [39]byte + C.dpiData_setBytes(&data.dpiData, (*C.char)(unsafe.Pointer(&a[0])), C.uint32_t(len(a))) } + //fmt.Printf("getAttributeValue(%p, %p, %d, %+v)\n", O.dpiObject, attr.dpiObjectAttr, data.NativeTypeNum, data.dpiData) - if C.dpiObject_getAttributeValue(O.dpiObject, attr.dpiObjectAttr, data.NativeTypeNum, data.dpiData) == C.DPI_FAILURE { - if wasNull { - C.free(unsafe.Pointer(data.dpiData)) - data.dpiData = nil - } - return errors.Wrapf(O.getError(), "getAttributeValue(obj=%+v, attr=%+v, typ=%d)", O, attr.dpiObjectAttr, data.NativeTypeNum) + if C.dpiObject_getAttributeValue(O.dpiObject, attr.dpiObjectAttr, data.NativeTypeNum, &data.dpiData) == C.DPI_FAILURE { + return errors.Errorf("getAttributeValue(%q, obj=%+v, attr=%+v, typ=%d): %w", name, O, attr.dpiObjectAttr, data.NativeTypeNum, O.getError()) } //fmt.Printf("getAttributeValue(%p, %q=%p, %d, %+v)\n", O.dpiObject, attr.Name, attr.dpiObjectAttr, data.NativeTypeNum, data.dpiData) return nil } -// SetAttribute sets the i-th attribute with data. +// SetAttribute sets the named attribute with data. func (O *Object) SetAttribute(name string, data *Data) error { + if !strings.Contains(name, `"`) { + name = strings.ToUpper(name) + } attr := O.Attributes[name] if data.NativeTypeNum == 0 { data.NativeTypeNum = attr.NativeTypeNum data.ObjectType = attr.ObjectType } - if C.dpiObject_setAttributeValue(O.dpiObject, attr.dpiObjectAttr, data.NativeTypeNum, data.dpiData) == C.DPI_FAILURE { + if C.dpiObject_setAttributeValue(O.dpiObject, attr.dpiObjectAttr, data.NativeTypeNum, &data.dpiData) == C.DPI_FAILURE { return O.getError() } return nil } -// ResetAttributes prepare all atributes for use the object as IN parameter +// Set is a convenience function to set the named attribute with the given value. +func (O *Object) Set(name string, v interface{}) error { + if data, ok := v.(*Data); ok { + return O.SetAttribute(name, data) + } + d := scratch.Get() + defer scratch.Put(d) + if err := d.Set(v); err != nil { + return err + } + return O.SetAttribute(name, d) +} + +// ResetAttributes prepare all attributes for use the object as IN parameter func (O *Object) ResetAttributes() error { var data Data for _, attr := range O.Attributes { @@ -95,10 +100,10 @@ func (O *Object) ResetAttributes() error { data.NativeTypeNum = attr.NativeTypeNum data.ObjectType = attr.ObjectType if attr.NativeTypeNum == C.DPI_NATIVE_TYPE_BYTES && attr.OracleTypeNum == C.DPI_ORACLE_TYPE_NUMBER { - var a [22]byte - C.dpiData_setBytes(data.dpiData, (*C.char)(unsafe.Pointer(&a[0])), 22) + a := make([]byte, attr.Precision) + C.dpiData_setBytes(&data.dpiData, (*C.char)(unsafe.Pointer(&a[0])), C.uint32_t(attr.Precision)) } - if C.dpiObject_setAttributeValue(O.dpiObject, attr.dpiObjectAttr, data.NativeTypeNum, data.dpiData) == C.DPI_FAILURE { + if C.dpiObject_setAttributeValue(O.dpiObject, attr.dpiObjectAttr, data.NativeTypeNum, &data.dpiData) == C.DPI_FAILURE { return O.getError() } } @@ -108,14 +113,16 @@ func (O *Object) ResetAttributes() error { // Get scans the named attribute into dest, and returns it. func (O *Object) Get(name string) (interface{}, error) { - if err := O.GetAttribute(&O.scratch, name); err != nil { + d := scratch.Get() + defer scratch.Put(d) + if err := O.GetAttribute(d, name); err != nil { return nil, err } - isObject := O.scratch.IsObject() + isObject := d.IsObject() if isObject { - O.scratch.ObjectType = O.Attributes[name].ObjectType + d.ObjectType = O.Attributes[name].ObjectType } - v := O.scratch.Get() + v := d.Get() if !isObject { return v, nil } @@ -131,15 +138,25 @@ func (O *Object) ObjectRef() *Object { return O } +// Collection returns &ObjectCollection{Object: O} iff the Object is a collection. +// Otherwise it returns nil. +func (O *Object) Collection() ObjectCollection { + if O.ObjectType.CollectionOf == nil { + return ObjectCollection{} + } + return ObjectCollection{Object: O} +} + // Close releases a reference to the object. func (O *Object) Close() error { - if O.dpiObject == nil { + obj := O.dpiObject + O.dpiObject = nil + if obj == nil { return nil } - if rc := C.dpiObject_release(O.dpiObject); rc == C.DPI_FAILURE { - return errors.Wrapf(O.getError(), "error on close object") + if C.dpiObject_release(obj) == C.DPI_FAILURE { + return errors.Errorf("error on close object: %w", O.getError()) } - O.dpiObject = nil return nil } @@ -156,21 +173,22 @@ var ErrNotCollection = errors.New("not collection") var ErrNotExist = errors.New("not exist") // AsSlice retrieves the collection into a slice. -func (O *ObjectCollection) AsSlice(dest interface{}) (interface{}, error) { - var data Data +func (O ObjectCollection) AsSlice(dest interface{}) (interface{}, error) { var dr reflect.Value needsInit := dest == nil if !needsInit { dr = reflect.ValueOf(dest) } + d := scratch.Get() + defer scratch.Put(d) for i, err := O.First(); err == nil; i, err = O.Next(i) { if O.CollectionOf.NativeTypeNum == C.DPI_NATIVE_TYPE_OBJECT { - data.ObjectType = *O.CollectionOf + d.ObjectType = *O.CollectionOf } - if err = O.Get(&data, i); err != nil { + if err = O.GetItem(d, i); err != nil { return dest, err } - vr := reflect.ValueOf(data.Get()) + vr := reflect.ValueOf(d.Get()) if needsInit { needsInit = false length, lengthErr := O.Len() @@ -184,31 +202,54 @@ func (O *ObjectCollection) AsSlice(dest interface{}) (interface{}, error) { return dr.Interface(), nil } -// Append data to the collection. -func (O *ObjectCollection) Append(data *Data) error { - if C.dpiObject_appendElement(O.dpiObject, data.NativeTypeNum, data.dpiData) == C.DPI_FAILURE { - return errors.Wrapf(O.getError(), "append(%d)", data.NativeTypeNum) +// AppendData to the collection. +func (O ObjectCollection) AppendData(data *Data) error { + if C.dpiObject_appendElement(O.dpiObject, data.NativeTypeNum, &data.dpiData) == C.DPI_FAILURE { + return errors.Errorf("append(%d): %w", data.NativeTypeNum, O.getError()) } return nil } +// Append v to the collection. +func (O ObjectCollection) Append(v interface{}) error { + if data, ok := v.(*Data); ok { + return O.AppendData(data) + } + d := scratch.Get() + defer scratch.Put(d) + if err := d.Set(v); err != nil { + return err + } + return O.AppendData(d) +} + +// AppendObject adds an Object to the collection. +func (O ObjectCollection) AppendObject(obj *Object) error { + d := scratch.Get() + defer scratch.Put(d) + d.ObjectType = obj.ObjectType + d.NativeTypeNum = C.DPI_NATIVE_TYPE_OBJECT + d.SetObject(obj) + return O.Append(d) +} + // Delete i-th element of the collection. -func (O *ObjectCollection) Delete(i int) error { +func (O ObjectCollection) Delete(i int) error { if C.dpiObject_deleteElementByIndex(O.dpiObject, C.int32_t(i)) == C.DPI_FAILURE { - return errors.Wrapf(O.getError(), "delete(%d)", i) + return errors.Errorf("delete(%d): %w", i, O.getError()) } return nil } -// Get the i-th element of the collection into data. -func (O *ObjectCollection) Get(data *Data, i int) error { +// GetItem gets the i-th element of the collection into data. +func (O ObjectCollection) GetItem(data *Data, i int) error { if data == nil { panic("data cannot be nil") } idx := C.int32_t(i) var exists C.int if C.dpiObject_getElementExistsByIndex(O.dpiObject, idx, &exists) == C.DPI_FAILURE { - return errors.Wrapf(O.getError(), "exists(%d)", idx) + return errors.Errorf("exists(%d): %w", idx, O.getError()) } if exists == 0 { return ErrNotExist @@ -216,26 +257,47 @@ func (O *ObjectCollection) Get(data *Data, i int) error { data.reset() data.NativeTypeNum = O.CollectionOf.NativeTypeNum data.ObjectType = *O.CollectionOf - if C.dpiObject_getElementValueByIndex(O.dpiObject, idx, data.NativeTypeNum, data.dpiData) == C.DPI_FAILURE { - return errors.Wrapf(O.getError(), "get(%d[%d])", idx, data.NativeTypeNum) + data.implicitObj = true + if C.dpiObject_getElementValueByIndex(O.dpiObject, idx, data.NativeTypeNum, &data.dpiData) == C.DPI_FAILURE { + return errors.Errorf("get(%d[%d]): %w", idx, data.NativeTypeNum, O.getError()) } return nil } -// Set the i-th element of the collection with data. -func (O *ObjectCollection) Set(i int, data *Data) error { - if C.dpiObject_setElementValueByIndex(O.dpiObject, C.int32_t(i), data.NativeTypeNum, data.dpiData) == C.DPI_FAILURE { - return errors.Wrapf(O.getError(), "set(%d[%d])", i, data.NativeTypeNum) +// Get the i-th element of the collection. +func (O ObjectCollection) Get(i int) (interface{}, error) { + var data Data + err := O.GetItem(&data, i) + return data.Get(), err +} + +// SetItem sets the i-th element of the collection with data. +func (O ObjectCollection) SetItem(i int, data *Data) error { + if C.dpiObject_setElementValueByIndex(O.dpiObject, C.int32_t(i), data.NativeTypeNum, &data.dpiData) == C.DPI_FAILURE { + return errors.Errorf("set(%d[%d]): %w", i, data.NativeTypeNum, O.getError()) } return nil } +// Set the i-th element of the collection with value. +func (O ObjectCollection) Set(i int, v interface{}) error { + if data, ok := v.(*Data); ok { + return O.SetItem(i, data) + } + d := scratch.Get() + defer scratch.Put(d) + if err := d.Set(v); err != nil { + return err + } + return O.SetItem(i, d) +} + // First returns the first element's index of the collection. -func (O *ObjectCollection) First() (int, error) { +func (O ObjectCollection) First() (int, error) { var exists C.int var idx C.int32_t if C.dpiObject_getFirstIndex(O.dpiObject, &idx, &exists) == C.DPI_FAILURE { - return 0, errors.Wrap(O.getError(), "first") + return 0, errors.Errorf("first: %w", O.getError()) } if exists == 1 { return int(idx), nil @@ -244,11 +306,11 @@ func (O *ObjectCollection) First() (int, error) { } // Last returns the index of the last element. -func (O *ObjectCollection) Last() (int, error) { +func (O ObjectCollection) Last() (int, error) { var exists C.int var idx C.int32_t if C.dpiObject_getLastIndex(O.dpiObject, &idx, &exists) == C.DPI_FAILURE { - return 0, errors.Wrap(O.getError(), "last") + return 0, errors.Errorf("last: %w", O.getError()) } if exists == 1 { return int(idx), nil @@ -257,11 +319,11 @@ func (O *ObjectCollection) Last() (int, error) { } // Next returns the succeeding index of i. -func (O *ObjectCollection) Next(i int) (int, error) { +func (O ObjectCollection) Next(i int) (int, error) { var exists C.int var idx C.int32_t if C.dpiObject_getNextIndex(O.dpiObject, C.int32_t(i), &idx, &exists) == C.DPI_FAILURE { - return 0, errors.Wrapf(O.getError(), "next(%d)", i) + return 0, errors.Errorf("next(%d): %w", i, O.getError()) } if exists == 1 { return int(idx), nil @@ -270,16 +332,16 @@ func (O *ObjectCollection) Next(i int) (int, error) { } // Len returns the length of the collection. -func (O *ObjectCollection) Len() (int, error) { +func (O ObjectCollection) Len() (int, error) { var size C.int32_t if C.dpiObject_getSize(O.dpiObject, &size) == C.DPI_FAILURE { - return 0, errors.Wrap(O.getError(), "len") + return 0, errors.Errorf("len: %w", O.getError()) } return int(size), nil } // Trim the collection to n. -func (O *ObjectCollection) Trim(n int) error { +func (O ObjectCollection) Trim(n int) error { if C.dpiObject_trim(O.dpiObject, C.uint32_t(n)) == C.DPI_FAILURE { return O.getError() } @@ -288,12 +350,14 @@ func (O *ObjectCollection) Trim(n int) error { // ObjectType holds type info of an Object. type ObjectType struct { - Schema, Name string + Schema, Name string + Attributes map[string]ObjectAttribute + + conn *conn + dpiObjectType *C.dpiObjectType + DBSize, ClientSizeInBytes, CharSize int CollectionOf *ObjectType - Attributes map[string]ObjectAttribute - dpiObjectType *C.dpiObjectType - drv *drv OracleTypeNum C.dpiOracleTypeNum NativeTypeNum C.dpiNativeTypeNum Precision int16 @@ -301,7 +365,14 @@ type ObjectType struct { FsPrecision uint8 } -func (t ObjectType) getError() error { return t.drv.getError() } +func (t ObjectType) getError() error { return t.conn.getError() } + +func (t ObjectType) String() string { + if t.Schema == "" { + return t.Name + } + return t.Schema + "." + t.Name +} // FullName returns the object's name with the schame prepended. func (t ObjectType) FullName() string { @@ -312,66 +383,111 @@ func (t ObjectType) FullName() string { } // GetObjectType returns the ObjectType of a name. +// +// The name is uppercased! Because here Oracle seems to be case-sensitive. +// To leave it as is, enclose it in "-s! func (c *conn) GetObjectType(name string) (ObjectType, error) { + c.mu.Lock() + defer c.mu.Unlock() + if !strings.Contains(name, "\"") { + name = strings.ToUpper(name) + } + if o, ok := c.objTypes[name]; ok { + return o, nil + } cName := C.CString(name) defer func() { C.free(unsafe.Pointer(cName)) }() objType := (*C.dpiObjectType)(C.malloc(C.sizeof_void)) if C.dpiConn_getObjectType(c.dpiConn, cName, C.uint32_t(len(name)), &objType) == C.DPI_FAILURE { C.free(unsafe.Pointer(objType)) - return ObjectType{}, errors.Wrapf(c.getError(), "getObjectType(%q) conn=%p", name, c.dpiConn) + return ObjectType{}, errors.Errorf("getObjectType(%q) conn=%p: %w", name, c.dpiConn, c.getError()) + } + t := ObjectType{conn: c, dpiObjectType: objType} + err := t.init() + if err == nil { + c.objTypes[name] = t + c.objTypes[t.FullName()] = t } - t := ObjectType{drv: c.drv, dpiObjectType: objType} - return t, t.init() + return t, err } // NewObject returns a new Object with ObjectType type. +// +// As with all Objects, you MUST call Close on it when not needed anymore! func (t ObjectType) NewObject() (*Object, error) { obj := (*C.dpiObject)(C.malloc(C.sizeof_void)) if C.dpiObjectType_createObject(t.dpiObjectType, &obj) == C.DPI_FAILURE { C.free(unsafe.Pointer(obj)) return nil, t.getError() } - return &Object{ObjectType: t, dpiObject: obj}, nil + O := &Object{ObjectType: t, dpiObject: obj} + // https://github.com/oracle/odpi/issues/112#issuecomment-524479532 + return O, O.ResetAttributes() +} + +// NewCollection returns a new Collection object with ObjectType type. +// If the ObjectType is not a Collection, it returns ErrNotCollection error. +func (t ObjectType) NewCollection() (ObjectCollection, error) { + if t.CollectionOf == nil { + return ObjectCollection{}, ErrNotCollection + } + O, err := t.NewObject() + if err != nil { + return ObjectCollection{}, err + } + return ObjectCollection{Object: O}, nil } // Close releases a reference to the object type. -func (t *ObjectType) Close() error { +func (t *ObjectType) close(doNotReuse bool) error { + if t == nil { + return nil + } + attributes, d := t.Attributes, t.dpiObjectType + t.Attributes, t.dpiObjectType = nil, nil + + if t.CollectionOf != nil { + err := t.CollectionOf.close(false) + if err != nil { + return err + } + } - for _, attr := range t.Attributes { + for _, attr := range attributes { err := attr.Close() if err != nil { return err } } - t.Attributes = nil - d := t.dpiObjectType - t.dpiObjectType = nil - if d == nil { + if d == nil || !doNotReuse { return nil } - if rc := C.dpiObjectType_release(d); rc == C.DPI_FAILURE { - return errors.Wrapf(t.getError(), "error on close object type") + if C.dpiObjectType_release(d) == C.DPI_FAILURE { + return errors.Errorf("error on close object type: %w", t.getError()) } return nil } -func wrapObject(d *drv, objectType *C.dpiObjectType, object *C.dpiObject) (*Object, error) { +func wrapObject(c *conn, objectType *C.dpiObjectType, object *C.dpiObject) (*Object, error) { if objectType == nil { return nil, errors.New("objectType is nil") } + if C.dpiObject_addRef(object) == C.DPI_FAILURE { + return nil, c.getError() + } o := &Object{ - ObjectType: ObjectType{dpiObjectType: objectType, drv: d}, + ObjectType: ObjectType{dpiObjectType: objectType, conn: c}, dpiObject: object, } return o, o.init() } func (t *ObjectType) init() error { - if t.drv == nil { - panic("drv is nil") + if t.conn == nil { + panic("conn is nil") } if t.Name != "" && t.Attributes != nil { return nil @@ -381,15 +497,18 @@ func (t *ObjectType) init() error { } var info C.dpiObjectTypeInfo if C.dpiObjectType_getInfo(t.dpiObjectType, &info) == C.DPI_FAILURE { - return errors.Wrapf(t.getError(), "%v.getInfo", t) + return errors.Errorf("%v.getInfo: %w", t, t.getError()) } t.Schema = C.GoStringN(info.schema, C.int(info.schemaLength)) t.Name = C.GoStringN(info.name, C.int(info.nameLength)) t.CollectionOf = nil - numAttributes := int(info.numAttributes) + if t.conn.objTypes == nil { + t.conn.objTypes = make(map[string]ObjectType) + } + numAttributes := int(info.numAttributes) if info.isCollection == 1 { - t.CollectionOf = &ObjectType{drv: t.drv} + t.CollectionOf = &ObjectType{conn: t.conn} if err := t.CollectionOf.fromDataTypeInfo(info.elementTypeInfo); err != nil { return err } @@ -398,6 +517,10 @@ func (t *ObjectType) init() error { t.CollectionOf.Name = t.Name } } + if ot, ok := t.conn.objTypes[t.FullName()]; ok { + t.Attributes = ot.Attributes + return nil + } if numAttributes == 0 { t.Attributes = map[string]ObjectAttribute{} return nil @@ -408,18 +531,18 @@ func (t *ObjectType) init() error { C.uint16_t(len(attrs)), (**C.dpiObjectAttr)(unsafe.Pointer(&attrs[0])), ) == C.DPI_FAILURE { - return errors.Wrapf(t.getError(), "%v.getAttributes", t) + return errors.Errorf("%v.getAttributes: %w", t, t.getError()) } for i, attr := range attrs { var attrInfo C.dpiObjectAttrInfo if C.dpiObjectAttr_getInfo(attr, &attrInfo) == C.DPI_FAILURE { - return errors.Wrapf(t.getError(), "%v.attr_getInfo", attr) + return errors.Errorf("%v.attr_getInfo: %w", attr, t.getError()) } if Log != nil { Log("i", i, "attrInfo", attrInfo) } typ := attrInfo.typeInfo - sub, err := objectTypeFromDataTypeInfo(t.drv, typ) + sub, err := objectTypeFromDataTypeInfo(t.conn, typ) if err != nil { return err } @@ -447,14 +570,14 @@ func (t *ObjectType) fromDataTypeInfo(typ C.dpiDataTypeInfo) error { t.FsPrecision = uint8(typ.fsPrecision) return t.init() } -func objectTypeFromDataTypeInfo(drv *drv, typ C.dpiDataTypeInfo) (ObjectType, error) { - if drv == nil { - panic("drv nil") +func objectTypeFromDataTypeInfo(conn *conn, typ C.dpiDataTypeInfo) (ObjectType, error) { + if conn == nil { + panic("conn is nil") } if typ.oracleTypeNum == 0 { panic("typ is nil") } - t := ObjectType{drv: drv} + t := ObjectType{conn: conn} err := t.fromDataTypeInfo(typ) return t, err } @@ -469,22 +592,35 @@ type ObjectAttribute struct { // Close the ObjectAttribute. func (A ObjectAttribute) Close() error { attr := A.dpiObjectAttr + A.dpiObjectAttr = nil + if attr == nil { return nil } - - A.dpiObjectAttr = nil if C.dpiObjectAttr_release(attr) == C.DPI_FAILURE { return A.getError() } + if A.ObjectType.dpiObjectType != nil { + err := A.ObjectType.close(false) + if err != nil { + return err + } + } return nil } // GetObjectType returns the ObjectType for the name. -func GetObjectType(ex Execer, typeName string) (ObjectType, error) { - c, err := getConn(ex) +func GetObjectType(ctx context.Context, ex Execer, typeName string) (ObjectType, error) { + c, err := getConn(ctx, ex) if err != nil { - return ObjectType{}, errors.WithMessage(err, "getConn for "+typeName) + return ObjectType{}, errors.Errorf("getConn for %s: %w", typeName, err) } return c.GetObjectType(typeName) } + +var scratch = &dataPool{Pool: sync.Pool{New: func() interface{} { return &Data{} }}} + +type dataPool struct{ sync.Pool } + +func (dp *dataPool) Get() *Data { return dp.Pool.Get().(*Data) } +func (dp *dataPool) Put(d *Data) { d.reset(); dp.Pool.Put(d) } diff --git a/vendor/gopkg.in/goracle.v2/odpi/CONTRIBUTING.md b/vendor/github.com/godror/godror/odpi/CONTRIBUTING.md similarity index 100% rename from vendor/gopkg.in/goracle.v2/odpi/CONTRIBUTING.md rename to vendor/github.com/godror/godror/odpi/CONTRIBUTING.md diff --git a/vendor/gopkg.in/goracle.v2/odpi/LICENSE.md b/vendor/github.com/godror/godror/odpi/LICENSE.md similarity index 99% rename from vendor/gopkg.in/goracle.v2/odpi/LICENSE.md rename to vendor/github.com/godror/godror/odpi/LICENSE.md index 20b6fc956fa..cb344b76c16 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/LICENSE.md +++ b/vendor/github.com/godror/godror/odpi/LICENSE.md @@ -215,4 +215,3 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS - diff --git a/vendor/gopkg.in/goracle.v2/odpi/README.md b/vendor/github.com/godror/godror/odpi/README.md similarity index 95% rename from vendor/gopkg.in/goracle.v2/odpi/README.md rename to vendor/github.com/godror/godror/odpi/README.md index a8e1decf845..fa911cc2130 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/README.md +++ b/vendor/github.com/godror/godror/odpi/README.md @@ -1,4 +1,4 @@ -# ODPI-C version 3.1 +# ODPI-C version 3.3 Oracle Database Programming Interface for C (ODPI-C) is an open source library of C code that simplifies access to Oracle Database for applications written in @@ -48,6 +48,7 @@ Third-party Drivers: * [ruby-ODPI ](https://github.com/kubo/ruby-odpi) Ruby Interface. * [rust-oracle ](https://github.com/kubo/rust-oracle) Driver for Rust. * [Oracle.jl](https://github.com/felipenoris/Oracle.jl) Driver for Julia. +* [oranif](https://github.com/K2InformaticsGmbH/oranif) Driver for Erlang. ## License diff --git a/vendor/gopkg.in/goracle.v2/odpi/embed/README.md b/vendor/github.com/godror/godror/odpi/embed/README.md similarity index 99% rename from vendor/gopkg.in/goracle.v2/odpi/embed/README.md rename to vendor/github.com/godror/godror/odpi/embed/README.md index 5dc0fb5ca15..dfe0b4524c0 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/embed/README.md +++ b/vendor/github.com/godror/godror/odpi/embed/README.md @@ -1,4 +1,3 @@ This directory contains the file dpi.c which can be used to embed ODPI-C within your project without having to manage the individual files that make up the library. The files can also be compiled independently if that is preferred. - diff --git a/vendor/gopkg.in/goracle.v2/odpi/embed/dpi.c b/vendor/github.com/godror/godror/odpi/embed/dpi.c similarity index 98% rename from vendor/gopkg.in/goracle.v2/odpi/embed/dpi.c rename to vendor/github.com/godror/godror/odpi/embed/dpi.c index e47f3f21460..7d0c6dc83bb 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/embed/dpi.c +++ b/vendor/github.com/godror/godror/odpi/embed/dpi.c @@ -37,6 +37,7 @@ #include "../src/dpiOci.c" #include "../src/dpiOracleType.c" #include "../src/dpiPool.c" +#include "../src/dpiQueue.c" #include "../src/dpiRowid.c" #include "../src/dpiSodaColl.c" #include "../src/dpiSodaCollCursor.c" @@ -47,4 +48,3 @@ #include "../src/dpiSubscr.c" #include "../src/dpiUtils.c" #include "../src/dpiVar.c" - diff --git a/vendor/gopkg.in/goracle.v2/odpi/include/dpi.h b/vendor/github.com/godror/godror/odpi/include/dpi.h similarity index 96% rename from vendor/gopkg.in/goracle.v2/odpi/include/dpi.h rename to vendor/github.com/godror/godror/odpi/include/dpi.h index 8606774900c..58b3a2d5867 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/include/dpi.h +++ b/vendor/github.com/godror/godror/odpi/include/dpi.h @@ -44,8 +44,8 @@ // define ODPI-C version information #define DPI_MAJOR_VERSION 3 -#define DPI_MINOR_VERSION 1 -#define DPI_PATCH_LEVEL 4 +#define DPI_MINOR_VERSION 3 +#define DPI_PATCH_LEVEL 0 #define DPI_VERSION_SUFFIX #define DPI_STR_HELPER(x) #x @@ -152,7 +152,6 @@ typedef uint32_t dpiEventType; #define DPI_EVENT_STARTUP 1 #define DPI_EVENT_SHUTDOWN 2 #define DPI_EVENT_SHUTDOWN_ANY 3 -#define DPI_EVENT_DROP_DB 4 #define DPI_EVENT_DEREG 5 #define DPI_EVENT_OBJCHANGE 6 #define DPI_EVENT_QUERYCHANGE 7 @@ -414,6 +413,7 @@ typedef struct dpiObjectAttrInfo dpiObjectAttrInfo; typedef struct dpiObjectTypeInfo dpiObjectTypeInfo; typedef struct dpiPoolCreateParams dpiPoolCreateParams; typedef struct dpiQueryInfo dpiQueryInfo; +typedef struct dpiQueue dpiQueue; typedef struct dpiShardingKeyColumn dpiShardingKeyColumn; typedef struct dpiSodaColl dpiSodaColl; typedef struct dpiSodaCollNames dpiSodaCollNames; @@ -571,6 +571,7 @@ struct dpiPoolCreateParams { uint32_t maxLifetimeSession; const char *plsqlFixupCallback; uint32_t plsqlFixupCallbackLength; + uint32_t maxSessionsPerShard; }; // structure used for transferring query metadata from ODPI-C @@ -642,6 +643,8 @@ struct dpiSubscrCreateParams { uint8_t groupingClass; uint32_t groupingValue; uint8_t groupingType; + uint64_t outRegId; + int clientInitiated; }; // structure used for transferring messages in subscription callbacks @@ -836,6 +839,10 @@ int dpiConn_newEnqOptions(dpiConn *conn, dpiEnqOptions **options); // create a new message properties object and return it int dpiConn_newMsgProps(dpiConn *conn, dpiMsgProps **props); +// create a new AQ queue +int dpiConn_newQueue(dpiConn *conn, const char *name, uint32_t nameLength, + dpiObjectType *payloadType, dpiQueue **queue); + // create a new temporary LOB int dpiConn_newTempLob(dpiConn *conn, dpiOracleTypeNum lobType, dpiLob **lob); @@ -1202,10 +1209,18 @@ int dpiMsgProps_getExceptionQ(dpiMsgProps *props, const char **value, // return the number of seconds until the message expires int dpiMsgProps_getExpiration(dpiMsgProps *props, int32_t *value); +// return the message id for the message (after enqueuing or dequeuing) +int dpiMsgProps_getMsgId(dpiMsgProps *props, const char **value, + uint32_t *valueLength); + // return the original message id for the message int dpiMsgProps_getOriginalMsgId(dpiMsgProps *props, const char **value, uint32_t *valueLength); +// return the payload of the message (object or bytes) +int dpiMsgProps_getPayload(dpiMsgProps *props, dpiObject **obj, + const char **value, uint32_t *valueLength); + // return the priority of the message int dpiMsgProps_getPriority(dpiMsgProps *props, int32_t *value); @@ -1233,6 +1248,13 @@ int dpiMsgProps_setExpiration(dpiMsgProps *props, int32_t value); int dpiMsgProps_setOriginalMsgId(dpiMsgProps *props, const char *value, uint32_t valueLength); +// set the payload of the message (as a series of bytes) +int dpiMsgProps_setPayloadBytes(dpiMsgProps *props, const char *value, + uint32_t valueLength); + +// set the payload of the message (as an object) +int dpiMsgProps_setPayloadObject(dpiMsgProps *props, dpiObject *obj); + // set the priority of the message int dpiMsgProps_setPriority(dpiMsgProps *props, int32_t value); @@ -1398,6 +1420,35 @@ int dpiPool_setTimeout(dpiPool *pool, uint32_t value); int dpiPool_setWaitTimeout(dpiPool *pool, uint32_t value); +//----------------------------------------------------------------------------- +// AQ Queue Methods (dpiQueue) +//----------------------------------------------------------------------------- + +// add a reference to the queue +int dpiQueue_addRef(dpiQueue *queue); + +// dequeue multiple messages from the queue +int dpiQueue_deqMany(dpiQueue *queue, uint32_t *numProps, dpiMsgProps **props); + +// dequeue a single message from the queue +int dpiQueue_deqOne(dpiQueue *queue, dpiMsgProps **props); + +// enqueue multiple message to the queue +int dpiQueue_enqMany(dpiQueue *queue, uint32_t numProps, dpiMsgProps **props); + +// enqueue a single message to the queue +int dpiQueue_enqOne(dpiQueue *queue, dpiMsgProps *props); + +// get a reference to the dequeue options associated with the queue +int dpiQueue_getDeqOptions(dpiQueue *queue, dpiDeqOptions **options); + +// get a reference to the enqueue options associated with the queue +int dpiQueue_getEnqOptions(dpiQueue *queue, dpiEnqOptions **options); + +// release a reference to the queue +int dpiQueue_release(dpiQueue *queue); + + //----------------------------------------------------------------------------- // SODA Collection Methods (dpiSodaColl) //----------------------------------------------------------------------------- @@ -1440,6 +1491,10 @@ int dpiSodaColl_getMetadata(dpiSodaColl *coll, const char **value, int dpiSodaColl_getName(dpiSodaColl *coll, const char **value, uint32_t *valueLength); +// insert multiple documents into the SODA collection +int dpiSodaColl_insertMany(dpiSodaColl *coll, uint32_t numDocs, + dpiSodaDoc **docs, uint32_t flags, dpiSodaDoc **insertedDocs); + // insert a document into the SODA collection int dpiSodaColl_insertOne(dpiSodaColl *coll, dpiSodaDoc *doc, uint32_t flags, dpiSodaDoc **insertedDoc); @@ -1644,6 +1699,9 @@ int dpiStmt_getImplicitResult(dpiStmt *stmt, dpiStmt **implicitResult); // return information about the statement int dpiStmt_getInfo(dpiStmt *stmt, dpiStmtInfo *info); +// get the rowid of the last row affected by a DML statement +int dpiStmt_getLastRowid(dpiStmt *stmt, dpiRowid **rowid); + // get the number of query columns (zero implies the statement is not a query) int dpiStmt_getNumQueryColumns(dpiStmt *stmt, uint32_t *numQueryColumns); @@ -1754,4 +1812,3 @@ int dpiVar_setFromStmt(dpiVar *var, uint32_t pos, dpiStmt *stmt); int dpiVar_setNumElementsInArray(dpiVar *var, uint32_t numElements); #endif - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiConn.c b/vendor/github.com/godror/godror/odpi/src/dpiConn.c similarity index 92% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiConn.c rename to vendor/github.com/godror/godror/odpi/src/dpiConn.c index e1c8edbe841..faa5dc5266b 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiConn.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiConn.c @@ -37,8 +37,7 @@ static int dpiConn__getSession(dpiConn *conn, uint32_t mode, static int dpiConn__setAttributesFromCreateParams(dpiConn *conn, void *handle, uint32_t handleType, const char *userName, uint32_t userNameLength, const char *password, uint32_t passwordLength, - const dpiConnCreateParams *params, void **shardingKey, - void **superShardingKey, dpiError *error); + const dpiConnCreateParams *params, dpiError *error); static int dpiConn__setShardingKey(dpiConn *conn, void **shardingKey, void *handle, uint32_t handleType, uint32_t attribute, const char *action, dpiShardingKeyColumn *columns, uint8_t numColumns, @@ -65,23 +64,6 @@ static int dpiConn__attachExternal(dpiConn *conn, void *externalHandle, return DPI_FAILURE; } - // allocate a new service context handle which will use the new environment - // handle independent of the original service context handle - conn->handle = NULL; - if (dpiOci__handleAlloc(conn->env->handle, &conn->handle, - DPI_OCI_HTYPE_SVCCTX, "allocate service context handle", - error) < 0) - return DPI_FAILURE; - - // set these handles on the newly created service context - if (dpiOci__attrSet(conn->handle, DPI_OCI_HTYPE_SVCCTX, conn->serverHandle, - 0, DPI_OCI_ATTR_SERVER, "set server handle", error) < 0) - return DPI_FAILURE; - if (dpiOci__attrSet(conn->handle, DPI_OCI_HTYPE_SVCCTX, - conn->sessionHandle, 0, DPI_OCI_ATTR_SESSION, "set session handle", - error) < 0) - return DPI_FAILURE; - return DPI_SUCCESS; } @@ -93,7 +75,7 @@ static int dpiConn__attachExternal(dpiConn *conn, void *externalHandle, //----------------------------------------------------------------------------- static int dpiConn__check(dpiConn *conn, const char *fnName, dpiError *error) { - if (dpiGen__startPublicFn(conn, DPI_HTYPE_CONN, fnName, 1, error) < 0) + if (dpiGen__startPublicFn(conn, DPI_HTYPE_CONN, fnName, error) < 0) return DPI_FAILURE; return dpiConn__checkConnected(conn, error); } @@ -224,8 +206,6 @@ static int dpiConn__close(dpiConn *conn, uint32_t mode, const char *tag, // handle connections created with an external handle if (conn->externalHandle) { - if (conn->handle) - dpiOci__handleFree(conn->handle, DPI_OCI_HTYPE_SVCCTX); conn->sessionHandle = NULL; // handle standalone connections @@ -254,7 +234,8 @@ static int dpiConn__close(dpiConn *conn, uint32_t mode, const char *tag, // update last time used (if the session isn't going to be dropped) // clear last time used (if the session is going to be dropped) - if (conn->sessionHandle) { + // do nothing, however, if not using a pool or the pool is being closed + if (conn->sessionHandle && conn->pool && conn->pool->handle) { // get the pointer from the context associated with the session lastTimeUsed = NULL; @@ -315,9 +296,20 @@ static int dpiConn__close(dpiConn *conn, uint32_t mode, const char *tag, conn->sessionHandle = NULL; } - conn->handle = NULL; conn->serverHandle = NULL; + + // destroy sharding and super sharding key descriptors, if applicable + if (conn->shardingKey) { + dpiOci__descriptorFree(conn->shardingKey, DPI_OCI_DTYPE_SHARDING_KEY); + conn->shardingKey = NULL; + } + if (conn->superShardingKey) { + dpiOci__descriptorFree(conn->superShardingKey, + DPI_OCI_DTYPE_SHARDING_KEY); + conn->superShardingKey = NULL; + } + return DPI_SUCCESS; } @@ -333,6 +325,8 @@ int dpiConn__create(dpiConn *conn, const dpiContext *context, const dpiCommonCreateParams *commonParams, dpiConnCreateParams *createParams, dpiError *error) { + void *envHandle = NULL; + // allocate handle lists for statements, LOBs and objects if (dpiHandleList__create(&conn->openStmts, error) < 0) return DPI_FAILURE; @@ -341,8 +335,29 @@ int dpiConn__create(dpiConn *conn, const dpiContext *context, if (dpiHandleList__create(&conn->objects, error) < 0) return DPI_FAILURE; + // if an external service context handle is provided, acquire the + // environment handle from it; need a temporary environment handle in order + // to do so + if (createParams->externalHandle) { + error->env = conn->env; + if (dpiOci__envNlsCreate(&conn->env->handle, DPI_OCI_DEFAULT, 0, 0, + error) < 0) + return DPI_FAILURE; + if (dpiOci__handleAlloc(conn->env->handle, &error->handle, + DPI_OCI_HTYPE_ERROR, "allocate temp OCI error", error) < 0) + return DPI_FAILURE; + if (dpiOci__attrGet(createParams->externalHandle, DPI_OCI_HTYPE_SVCCTX, + &envHandle, NULL, DPI_OCI_ATTR_ENV, "get env handle", + error) < 0) + return DPI_FAILURE; + dpiOci__handleFree(conn->env->handle, DPI_OCI_HTYPE_ENV); + error->handle = NULL; + conn->env->handle = NULL; + } + // initialize environment (for non-pooled connections) - if (!pool && dpiEnv__init(conn->env, context, commonParams, error) < 0) + if (!pool && dpiEnv__init(conn->env, context, commonParams, envHandle, + error) < 0) return DPI_FAILURE; // if a handle is specified, use it @@ -416,7 +431,7 @@ static int dpiConn__createStandalone(dpiConn *conn, const char *userName, // populate attributes on the session handle if (dpiConn__setAttributesFromCreateParams(conn, conn->sessionHandle, DPI_OCI_HTYPE_SESSION, userName, userNameLength, password, - passwordLength, createParams, NULL, NULL, error) < 0) + passwordLength, createParams, error) < 0) return DPI_FAILURE; // set the session handle on the service context handle @@ -505,11 +520,16 @@ static int dpiConn__get(dpiConn *conn, const char *userName, const char *connectString, uint32_t connectStringLength, dpiConnCreateParams *createParams, dpiPool *pool, dpiError *error) { - void *shardingKey = NULL, *superShardingKey = NULL; int externalAuth, status; void *authInfo; uint32_t mode; + // clear pointers if length is 0 + if (userNameLength == 0) + userName = NULL; + if (passwordLength == 0) + password = NULL; + // set things up for the call to acquire a session if (pool) { dpiGen__setRefCount(pool, error, 1); @@ -547,8 +567,7 @@ static int dpiConn__get(dpiConn *conn, const char *userName, // set attributes for create parameters if (dpiConn__setAttributesFromCreateParams(conn, authInfo, DPI_OCI_HTYPE_AUTHINFO, userName, userNameLength, password, - passwordLength, createParams, &shardingKey, &superShardingKey, - error) < 0) { + passwordLength, createParams, error) < 0) { dpiOci__handleFree(authInfo, DPI_OCI_HTYPE_AUTHINFO); return DPI_FAILURE; } @@ -556,13 +575,6 @@ static int dpiConn__get(dpiConn *conn, const char *userName, // get a session from the pool status = dpiConn__getSession(conn, mode, connectString, connectStringLength, createParams, authInfo, error); - if (status == DPI_SUCCESS && pool) { - if (shardingKey) - dpiOci__descriptorFree(shardingKey, DPI_OCI_DTYPE_SHARDING_KEY); - if (superShardingKey) - dpiOci__descriptorFree(superShardingKey, - DPI_OCI_DTYPE_SHARDING_KEY); - } dpiOci__handleFree(authInfo, DPI_OCI_HTYPE_AUTHINFO); if (status < 0) return status; @@ -630,6 +642,19 @@ static int dpiConn__getHandles(dpiConn *conn, dpiError *error) } +//----------------------------------------------------------------------------- +// dpiConn__getRawTDO() [INTERNAL] +// Internal method used for ensuring that the RAW TDO has been cached on the +//connection. +//----------------------------------------------------------------------------- +int dpiConn__getRawTDO(dpiConn *conn, dpiError *error) +{ + if (conn->rawTDO) + return DPI_SUCCESS; + return dpiOci__typeByName(conn, "SYS", 3, "RAW", 3, &conn->rawTDO, error); +} + + //----------------------------------------------------------------------------- // dpiConn__getServerCharset() [INTERNAL] // Internal method used for retrieving the server character set. This is used @@ -850,8 +875,7 @@ static int dpiConn__setAppContext(void *handle, uint32_t handleType, static int dpiConn__setAttributesFromCreateParams(dpiConn *conn, void *handle, uint32_t handleType, const char *userName, uint32_t userNameLength, const char *password, uint32_t passwordLength, - const dpiConnCreateParams *params, void **shardingKey, - void **superShardingKey, dpiError *error) + const dpiConnCreateParams *params, dpiError *error) { uint32_t purity; @@ -882,17 +906,20 @@ static int dpiConn__setAttributesFromCreateParams(dpiConn *conn, void *handle, // set sharding key and super sharding key parameters if (params->shardingKeyColumns && params->numShardingKeyColumns > 0) { - if (dpiConn__setShardingKey(conn, shardingKey, handle, handleType, - DPI_OCI_ATTR_SHARDING_KEY, "set sharding key", + if (dpiConn__setShardingKey(conn, &conn->shardingKey, handle, + handleType, DPI_OCI_ATTR_SHARDING_KEY, "set sharding key", params->shardingKeyColumns, params->numShardingKeyColumns, error) < 0) return DPI_FAILURE; } if (params->superShardingKeyColumns && params->numSuperShardingKeyColumns > 0) { - if (dpiConn__setShardingKey(conn, superShardingKey, handle, handleType, - DPI_OCI_ATTR_SUPER_SHARDING_KEY, "set super sharding key", - params->superShardingKeyColumns, + if (params->numShardingKeyColumns == 0) + return dpiError__set(error, "ensure sharding key", + DPI_ERR_MISSING_SHARDING_KEY); + if (dpiConn__setShardingKey(conn, &conn->superShardingKey, handle, + handleType, DPI_OCI_ATTR_SUPER_SHARDING_KEY, + "set super sharding key", params->superShardingKeyColumns, params->numSuperShardingKeyColumns, error) < 0) return DPI_FAILURE; } @@ -995,13 +1022,14 @@ static int dpiConn__setShardingKey(dpiConn *conn, void **shardingKey, static int dpiConn__setShardingKeyValue(dpiConn *conn, void *shardingKey, dpiShardingKeyColumn *column, dpiError *error) { + dpiShardingOciDate shardingDateValue; + uint32_t colLen = 0, descType = 0; const dpiOracleType *oracleType; dpiOciNumber numberValue; + int convertOk, status; dpiOciDate dateValue; - uint32_t colLen = 0; void *col = NULL; uint16_t colType; - int convertOk; oracleType = dpiOracleType__getFromNum(column->oracleTypeNum, error); if (!oracleType) @@ -1044,14 +1072,61 @@ static int dpiConn__setShardingKeyValue(dpiConn *conn, void *shardingKey, } break; case DPI_ORACLE_TYPE_DATE: - col = &dateValue; - colLen = sizeof(dateValue); - colType = DPI_SQLT_DAT; if (column->nativeTypeNum == DPI_NATIVE_TYPE_TIMESTAMP) { if (dpiDataBuffer__toOracleDate(&column->value, &dateValue) < 0) return DPI_FAILURE; convertOk = 1; + } else if (column->nativeTypeNum == DPI_NATIVE_TYPE_DOUBLE) { + if (dpiDataBuffer__toOracleDateFromDouble(&column->value, + conn->env, error, &dateValue) < 0) + return DPI_FAILURE; + convertOk = 1; + } + + // for sharding only, the type must be SQLT_DAT, which uses a + // different format for storing the date values + if (convertOk) { + col = &shardingDateValue; + colLen = sizeof(shardingDateValue); + colType = DPI_SQLT_DAT; + shardingDateValue.century = + ((uint8_t) (dateValue.year / 100)) + 100; + shardingDateValue.year = (dateValue.year % 100) + 100; + shardingDateValue.month = dateValue.month; + shardingDateValue.day = dateValue.day; + shardingDateValue.hour = dateValue.hour + 1; + shardingDateValue.minute = dateValue.minute + 1; + shardingDateValue.second = dateValue.second + 1; + } + break; + case DPI_ORACLE_TYPE_TIMESTAMP: + case DPI_ORACLE_TYPE_TIMESTAMP_TZ: + case DPI_ORACLE_TYPE_TIMESTAMP_LTZ: + colLen = sizeof(void*); + colType = DPI_SQLT_TIMESTAMP; + if (column->nativeTypeNum == DPI_NATIVE_TYPE_TIMESTAMP) { + descType = DPI_OCI_DTYPE_TIMESTAMP; + if (dpiOci__descriptorAlloc(conn->env->handle, &col, descType, + "alloc timestamp", error) < 0) + return DPI_FAILURE; + if (dpiDataBuffer__toOracleTimestamp(&column->value, conn->env, + error, col, 0) < 0) { + dpiOci__descriptorFree(col, descType); + return DPI_FAILURE; + } + convertOk = 1; + } else if (column->nativeTypeNum == DPI_NATIVE_TYPE_DOUBLE) { + descType = DPI_OCI_DTYPE_TIMESTAMP_LTZ; + if (dpiOci__descriptorAlloc(conn->env->handle, &col, descType, + "alloc LTZ timestamp", error) < 0) + return DPI_FAILURE; + if (dpiDataBuffer__toOracleTimestampFromDouble(&column->value, + conn->env, error, col) < 0) { + dpiOci__descriptorFree(col, descType); + return DPI_FAILURE; + } + convertOk = 1; } break; default: @@ -1060,8 +1135,11 @@ static int dpiConn__setShardingKeyValue(dpiConn *conn, void *shardingKey, if (!convertOk) return dpiError__set(error, "check type", DPI_ERR_NOT_SUPPORTED); - return dpiOci__shardingKeyColumnAdd(shardingKey, col, colLen, colType, + status = dpiOci__shardingKeyColumnAdd(shardingKey, col, colLen, colType, error); + if (descType) + dpiOci__descriptorFree(col, descType); + return status; } @@ -1282,7 +1360,7 @@ int dpiConn_create(const dpiContext *context, const char *userName, int status; // validate parameters - if (dpiGen__startPublicFn(context, DPI_HTYPE_CONTEXT, __func__, 0, + if (dpiGen__startPublicFn(context, DPI_HTYPE_CONTEXT, __func__, &error) < 0) return dpiGen__endPublicFn(context, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(context, conn) @@ -1347,8 +1425,6 @@ int dpiConn_create(const dpiContext *context, const char *userName, dpiError__set(&error, "check pool", DPI_ERR_NOT_CONNECTED); return dpiGen__endPublicFn(context, DPI_FAILURE, &error); } - if (dpiEnv__initError(createParams->pool->env, &error) < 0) - return dpiGen__endPublicFn(context, DPI_FAILURE, &error); status = dpiPool__acquireConnection(createParams->pool, userName, userNameLength, password, passwordLength, createParams, conn, &error); @@ -1366,8 +1442,7 @@ int dpiConn_create(const dpiContext *context, const char *userName, } *conn = tempConn; - dpiHandlePool__release(tempConn->env->errorHandles, error.handle, &error); - error.handle = NULL; + dpiHandlePool__release(tempConn->env->errorHandles, &error.handle); return dpiGen__endPublicFn(context, DPI_SUCCESS, &error); } @@ -1404,7 +1479,6 @@ int dpiConn_deqObject(dpiConn *conn, const char *queueName, uint32_t queueNameLength, dpiDeqOptions *options, dpiMsgProps *props, dpiObject *payload, const char **msgId, uint32_t *msgIdLength) { - void *ociMsgId = NULL; dpiError error; // validate parameters @@ -1426,19 +1500,15 @@ int dpiConn_deqObject(dpiConn *conn, const char *queueName, // dequeue message if (dpiOci__aqDeq(conn, queueName, options->handle, props->handle, payload->type->tdo, &payload->instance, &payload->indicator, - &ociMsgId, &error) < 0) { + &props->msgIdRaw, &error) < 0) { if (error.buffer->code == 25228) { - if (ociMsgId) - dpiOci__rawResize(conn->env->handle, &ociMsgId, 0, &error); *msgId = NULL; *msgIdLength = 0; return dpiGen__endPublicFn(conn, DPI_SUCCESS, &error); } return dpiGen__endPublicFn(conn, DPI_FAILURE, &error); } - if (dpiMsgProps__extractMsgId(props, ociMsgId, msgId, msgIdLength, - &error) < 0) - return dpiGen__endPublicFn(conn, DPI_FAILURE, &error); + dpiMsgProps__extractMsgId(props, msgId, msgIdLength); return dpiGen__endPublicFn(conn, DPI_SUCCESS, &error); } @@ -1451,7 +1521,6 @@ int dpiConn_enqObject(dpiConn *conn, const char *queueName, uint32_t queueNameLength, dpiEnqOptions *options, dpiMsgProps *props, dpiObject *payload, const char **msgId, uint32_t *msgIdLength) { - void *ociMsgId = NULL; dpiError error; // validate parameters @@ -1473,11 +1542,9 @@ int dpiConn_enqObject(dpiConn *conn, const char *queueName, // enqueue message if (dpiOci__aqEnq(conn, queueName, options->handle, props->handle, payload->type->tdo, &payload->instance, &payload->indicator, - &ociMsgId, &error) < 0) - return dpiGen__endPublicFn(conn, DPI_FAILURE, &error); - if (dpiMsgProps__extractMsgId(props, ociMsgId, msgId, msgIdLength, - &error) < 0) + &props->msgIdRaw, &error) < 0) return dpiGen__endPublicFn(conn, DPI_FAILURE, &error); + dpiMsgProps__extractMsgId(props, msgId, msgIdLength); return dpiGen__endPublicFn(conn, DPI_SUCCESS, &error); } @@ -1682,15 +1749,15 @@ int dpiConn_getServerVersion(dpiConn *conn, const char **releaseString, // validate parameters if (dpiConn__check(conn, __func__, &error) < 0) return dpiGen__endPublicFn(conn, DPI_FAILURE, &error); - DPI_CHECK_PTR_NOT_NULL(conn, releaseString) - DPI_CHECK_PTR_NOT_NULL(conn, releaseStringLength) DPI_CHECK_PTR_NOT_NULL(conn, versionInfo) // get server version if (dpiConn__getServerVersion(conn, &error) < 0) return dpiGen__endPublicFn(conn, DPI_FAILURE, &error); - *releaseString = conn->releaseString; - *releaseStringLength = conn->releaseStringLength; + if (releaseString) + *releaseString = conn->releaseString; + if (releaseStringLength) + *releaseStringLength = conn->releaseStringLength; memcpy(versionInfo, &conn->versionInfo, sizeof(dpiVersionInfo)); return dpiGen__endPublicFn(conn, DPI_SUCCESS, &error); } @@ -1806,22 +1873,34 @@ int dpiConn_newTempLob(dpiConn *conn, dpiOracleTypeNum lobType, dpiLob **lob) //----------------------------------------------------------------------------- int dpiConn_newMsgProps(dpiConn *conn, dpiMsgProps **props) { - dpiMsgProps *tempProps; dpiError error; + int status; if (dpiConn__check(conn, __func__, &error) < 0) return dpiGen__endPublicFn(conn, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(conn, props) - if (dpiGen__allocate(DPI_HTYPE_MSG_PROPS, conn->env, (void**) &tempProps, - &error) < 0) - return dpiGen__endPublicFn(conn, DPI_FAILURE, &error); - if (dpiMsgProps__create(tempProps, conn, &error) < 0) { - dpiMsgProps__free(tempProps, &error); - return dpiGen__endPublicFn(conn, DPI_FAILURE, &error); - } + status = dpiMsgProps__allocate(conn, props, &error); + return dpiGen__endPublicFn(conn, status, &error); +} - *props = tempProps; - return dpiGen__endPublicFn(conn, DPI_SUCCESS, &error); + +//----------------------------------------------------------------------------- +// dpiConn_newQueue() [PUBLIC] +// Create a new AQ queue object and return it. +//----------------------------------------------------------------------------- +int dpiConn_newQueue(dpiConn *conn, const char *name, uint32_t nameLength, + dpiObjectType *payloadType, dpiQueue **queue) +{ + dpiError error; + int status; + + if (dpiConn__check(conn, __func__, &error) < 0) + return dpiGen__endPublicFn(conn, DPI_FAILURE, &error); + DPI_CHECK_PTR_AND_LENGTH(conn, name) + DPI_CHECK_PTR_NOT_NULL(conn, queue) + status = dpiQueue__allocate(conn, name, nameLength, payloadType, queue, + &error); + return dpiGen__endPublicFn(conn, status, &error); } @@ -2148,6 +2227,7 @@ int dpiConn_subscribe(dpiConn *conn, dpiSubscrCreateParams *params, int dpiConn_unsubscribe(dpiConn *conn, dpiSubscr *subscr) { dpiError error; + int status; if (dpiConn__check(conn, __func__, &error) < 0) return dpiGen__endPublicFn(conn, DPI_FAILURE, &error); @@ -2155,12 +2235,15 @@ int dpiConn_unsubscribe(dpiConn *conn, dpiSubscr *subscr) &error) < 0) return dpiGen__endPublicFn(conn, DPI_FAILURE, &error); if (subscr->registered) { - if (dpiOci__subscriptionUnRegister(conn, subscr, &error) < 0) + dpiMutex__acquire(subscr->mutex); + status = dpiOci__subscriptionUnRegister(conn, subscr, &error); + if (status == DPI_SUCCESS) + subscr->registered = 0; + dpiMutex__release(subscr->mutex); + if (status < 0) return dpiGen__endPublicFn(subscr, DPI_FAILURE, &error); - subscr->registered = 0; } dpiGen__setRefCount(subscr, &error, -1); return dpiGen__endPublicFn(subscr, DPI_SUCCESS, &error); } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiContext.c b/vendor/github.com/godror/godror/odpi/src/dpiContext.c similarity index 92% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiContext.c rename to vendor/github.com/godror/godror/odpi/src/dpiContext.c index 315afe32ea9..e9adb18a33e 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiContext.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiContext.c @@ -156,7 +156,7 @@ int dpiContext_destroy(dpiContext *context) char message[80]; dpiError error; - if (dpiGen__startPublicFn(context, DPI_HTYPE_CONTEXT, __func__, 0, + if (dpiGen__startPublicFn(context, DPI_HTYPE_CONTEXT, __func__, &error) < 0) return dpiGen__endPublicFn(context, DPI_FAILURE, &error); dpiUtils__clearMemory(&context->checkInt, sizeof(context->checkInt)); @@ -181,7 +181,7 @@ int dpiContext_getClientVersion(const dpiContext *context, { dpiError error; - if (dpiGen__startPublicFn(context, DPI_HTYPE_CONTEXT, __func__, 0, + if (dpiGen__startPublicFn(context, DPI_HTYPE_CONTEXT, __func__, &error) < 0) return dpiGen__endPublicFn(context, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(context, versionInfo) @@ -214,7 +214,7 @@ int dpiContext_initCommonCreateParams(const dpiContext *context, { dpiError error; - if (dpiGen__startPublicFn(context, DPI_HTYPE_CONTEXT, __func__, 0, + if (dpiGen__startPublicFn(context, DPI_HTYPE_CONTEXT, __func__, &error) < 0) return dpiGen__endPublicFn(context, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(context, params) @@ -233,7 +233,7 @@ int dpiContext_initConnCreateParams(const dpiContext *context, dpiConnCreateParams localParams; dpiError error; - if (dpiGen__startPublicFn(context, DPI_HTYPE_CONTEXT, __func__, 0, + if (dpiGen__startPublicFn(context, DPI_HTYPE_CONTEXT, __func__, &error) < 0) return dpiGen__endPublicFn(context, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(context, params) @@ -259,17 +259,22 @@ int dpiContext_initPoolCreateParams(const dpiContext *context, dpiPoolCreateParams localParams; dpiError error; - if (dpiGen__startPublicFn(context, DPI_HTYPE_CONTEXT, __func__, 0, + if (dpiGen__startPublicFn(context, DPI_HTYPE_CONTEXT, __func__, &error) < 0) return dpiGen__endPublicFn(context, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(context, params) - // size changed in version 3.1; can be dropped once version 4 released - if (context->dpiMinorVersion > 0) + // size changed in versions 3.1 and 3.3 + // changes can be dropped once version 4 released + if (context->dpiMinorVersion > 2) { dpiContext__initPoolCreateParams(params); - else { + } else { dpiContext__initPoolCreateParams(&localParams); - memcpy(params, &localParams, sizeof(dpiPoolCreateParams__v30)); + if (context->dpiMinorVersion > 0) { + memcpy(params, &localParams, sizeof(dpiPoolCreateParams__v32)); + } else { + memcpy(params, &localParams, sizeof(dpiPoolCreateParams__v30)); + } } return dpiGen__endPublicFn(context, DPI_SUCCESS, &error); } @@ -284,7 +289,7 @@ int dpiContext_initSodaOperOptions(const dpiContext *context, { dpiError error; - if (dpiGen__startPublicFn(context, DPI_HTYPE_CONTEXT, __func__, 0, + if (dpiGen__startPublicFn(context, DPI_HTYPE_CONTEXT, __func__, &error) < 0) return dpiGen__endPublicFn(context, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(context, options) @@ -300,13 +305,25 @@ int dpiContext_initSodaOperOptions(const dpiContext *context, int dpiContext_initSubscrCreateParams(const dpiContext *context, dpiSubscrCreateParams *params) { + dpiSubscrCreateParams localParams; dpiError error; - if (dpiGen__startPublicFn(context, DPI_HTYPE_CONTEXT, __func__, 0, + if (dpiGen__startPublicFn(context, DPI_HTYPE_CONTEXT, __func__, &error) < 0) return dpiGen__endPublicFn(context, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(context, params) - dpiContext__initSubscrCreateParams(params); + + // size changed in versions 3.2 and 3.3 + // changes can be dropped once version 4 released + if (context->dpiMinorVersion > 2) { + dpiContext__initSubscrCreateParams(params); + } else { + dpiContext__initSubscrCreateParams(&localParams); + if (context->dpiMinorVersion > 1) { + memcpy(params, &localParams, sizeof(dpiSubscrCreateParams__v32)); + } else { + memcpy(params, &localParams, sizeof(dpiSubscrCreateParams__v30)); + } + } return dpiGen__endPublicFn(context, DPI_SUCCESS, &error); } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiData.c b/vendor/github.com/godror/godror/odpi/src/dpiData.c similarity index 89% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiData.c rename to vendor/github.com/godror/godror/odpi/src/dpiData.c index dc669f4bc7f..57d3faac309 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiData.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiData.c @@ -46,6 +46,36 @@ int dpiDataBuffer__fromOracleDate(dpiDataBuffer *data, } +//----------------------------------------------------------------------------- +// dpiDataBuffer__fromOracleDateAsDouble() [INTERNAL] +// Populate the data from an dpiOciDate structure as a double value (number +// of milliseconds since January 1, 1970). +//----------------------------------------------------------------------------- +int dpiDataBuffer__fromOracleDateAsDouble(dpiDataBuffer *data, + dpiEnv *env, dpiError *error, dpiOciDate *oracleValue) +{ + void *timestamp; + int status; + + // allocate and populate a timestamp with the value of the date + if (dpiOci__descriptorAlloc(env->handle, ×tamp, + DPI_OCI_DTYPE_TIMESTAMP_LTZ, "alloc timestamp", error) < 0) + return DPI_FAILURE; + if (dpiOci__dateTimeConstruct(env->handle, timestamp, oracleValue->year, + oracleValue->month, oracleValue->day, oracleValue->hour, + oracleValue->minute, oracleValue->second, 0, NULL, 0, error) < 0) { + dpiOci__descriptorFree(timestamp, DPI_OCI_DTYPE_TIMESTAMP_LTZ); + return DPI_FAILURE; + } + + // now calculate the number of milliseconds since January 1, 1970 + status = dpiDataBuffer__fromOracleTimestampAsDouble(data, env, error, + timestamp); + dpiOci__descriptorFree(timestamp, DPI_OCI_DTYPE_TIMESTAMP_LTZ); + return status; +} + + //----------------------------------------------------------------------------- // dpiDataBuffer__fromOracleIntervalDS() [INTERNAL] // Populate the data from an OCIInterval structure (days/seconds). @@ -305,6 +335,58 @@ int dpiDataBuffer__toOracleDate(dpiDataBuffer *data, dpiOciDate *oracleValue) } +//----------------------------------------------------------------------------- +// dpiDataBuffer__toOracleDateFromDouble() [INTERNAL] +// Populate the data in an dpiOciDate structure given a double (number of +// milliseconds since January 1, 1970). +//----------------------------------------------------------------------------- +int dpiDataBuffer__toOracleDateFromDouble(dpiDataBuffer *data, dpiEnv *env, + dpiError *error, dpiOciDate *oracleValue) +{ + void *timestamp, *timestampLTZ; + uint32_t fsecond; + + // allocate a descriptor to acquire a timestamp + if (dpiOci__descriptorAlloc(env->handle, ×tampLTZ, + DPI_OCI_DTYPE_TIMESTAMP_LTZ, "alloc timestamp", error) < 0) + return DPI_FAILURE; + if (dpiDataBuffer__toOracleTimestampFromDouble(data, env, error, + timestampLTZ) < 0) { + dpiOci__descriptorFree(timestampLTZ, DPI_OCI_DTYPE_TIMESTAMP_LTZ); + return DPI_FAILURE; + } + + // allocate a plain timestamp and convert to it + if (dpiOci__descriptorAlloc(env->handle, ×tamp, + DPI_OCI_DTYPE_TIMESTAMP, "alloc plain timestamp", error) < 0) { + dpiOci__descriptorFree(timestampLTZ, DPI_OCI_DTYPE_TIMESTAMP_LTZ); + return DPI_FAILURE; + } + if (dpiOci__dateTimeConvert(env->handle, timestampLTZ, timestamp, + error) < 0) { + dpiOci__descriptorFree(timestamp, DPI_OCI_DTYPE_TIMESTAMP); + dpiOci__descriptorFree(timestampLTZ, DPI_OCI_DTYPE_TIMESTAMP_LTZ); + return DPI_FAILURE; + } + dpiOci__descriptorFree(timestampLTZ, DPI_OCI_DTYPE_TIMESTAMP_LTZ); + + // populate date structure + if (dpiOci__dateTimeGetDate(env->handle, timestamp, &oracleValue->year, + &oracleValue->month, &oracleValue->day, error) < 0) { + dpiOci__descriptorFree(timestamp, DPI_OCI_DTYPE_TIMESTAMP); + return DPI_FAILURE; + } + if (dpiOci__dateTimeGetTime(env->handle, timestamp, &oracleValue->hour, + &oracleValue->minute, &oracleValue->second, &fsecond, error) < 0) { + dpiOci__descriptorFree(timestamp, DPI_OCI_DTYPE_TIMESTAMP); + return DPI_FAILURE; + } + + dpiOci__descriptorFree(timestamp, DPI_OCI_DTYPE_TIMESTAMP); + return DPI_SUCCESS; +} + + //----------------------------------------------------------------------------- // dpiDataBuffer__toOracleIntervalDS() [INTERNAL] // Populate the data in an OCIInterval structure (days/seconds). @@ -815,4 +897,3 @@ void dpiData_setUint64(dpiData *data, uint64_t value) data->isNull = 0; data->value.asUint64 = value; } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiDebug.c b/vendor/github.com/godror/godror/odpi/src/dpiDebug.c similarity index 99% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiDebug.c rename to vendor/github.com/godror/godror/odpi/src/dpiDebug.c index 6188d7d84a7..28b8776475f 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiDebug.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiDebug.c @@ -181,4 +181,3 @@ void dpiDebug__print(const char *format, ...) (void) vfprintf(dpiDebugStream, formatWithPrefix, varArgs); va_end(varArgs); } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiDeqOptions.c b/vendor/github.com/godror/godror/odpi/src/dpiDeqOptions.c similarity index 99% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiDeqOptions.c rename to vendor/github.com/godror/godror/odpi/src/dpiDeqOptions.c index 309eb05e5a6..35cb84727ae 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiDeqOptions.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiDeqOptions.c @@ -60,7 +60,7 @@ static int dpiDeqOptions__getAttrValue(dpiDeqOptions *options, dpiError error; int status; - if (dpiGen__startPublicFn(options, DPI_HTYPE_DEQ_OPTIONS, fnName, 1, + if (dpiGen__startPublicFn(options, DPI_HTYPE_DEQ_OPTIONS, fnName, &error) < 0) return dpiGen__endPublicFn(options, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(options, value) @@ -82,7 +82,7 @@ static int dpiDeqOptions__setAttrValue(dpiDeqOptions *options, dpiError error; int status; - if (dpiGen__startPublicFn(options, DPI_HTYPE_DEQ_OPTIONS, fnName, 1, + if (dpiGen__startPublicFn(options, DPI_HTYPE_DEQ_OPTIONS, fnName, &error) < 0) return dpiGen__endPublicFn(options, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(options, value) @@ -162,7 +162,7 @@ int dpiDeqOptions_getMsgId(dpiDeqOptions *options, const char **value, dpiError error; void *rawValue; - if (dpiGen__startPublicFn(options, DPI_HTYPE_DEQ_OPTIONS, __func__, 1, + if (dpiGen__startPublicFn(options, DPI_HTYPE_DEQ_OPTIONS, __func__, &error) < 0) return dpiGen__endPublicFn(options, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(options, value) @@ -309,7 +309,7 @@ int dpiDeqOptions_setMsgId(dpiDeqOptions *options, const char *value, dpiError error; int status; - if (dpiGen__startPublicFn(options, DPI_HTYPE_DEQ_OPTIONS, __func__, 1, + if (dpiGen__startPublicFn(options, DPI_HTYPE_DEQ_OPTIONS, __func__, &error) < 0) return dpiGen__endPublicFn(options, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(options, value) @@ -367,4 +367,3 @@ int dpiDeqOptions_setWait(dpiDeqOptions *options, uint32_t value) return dpiDeqOptions__setAttrValue(options, DPI_OCI_ATTR_WAIT, __func__, &value, 0); } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiEnqOptions.c b/vendor/github.com/godror/godror/odpi/src/dpiEnqOptions.c similarity index 99% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiEnqOptions.c rename to vendor/github.com/godror/godror/odpi/src/dpiEnqOptions.c index 8b073188c33..24bf60a3229 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiEnqOptions.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiEnqOptions.c @@ -60,7 +60,7 @@ static int dpiEnqOptions__getAttrValue(dpiEnqOptions *options, dpiError error; int status; - if (dpiGen__startPublicFn(options, DPI_HTYPE_ENQ_OPTIONS, fnName, 1, + if (dpiGen__startPublicFn(options, DPI_HTYPE_ENQ_OPTIONS, fnName, &error) < 0) return dpiGen__endPublicFn(options, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(options, value) @@ -82,7 +82,7 @@ static int dpiEnqOptions__setAttrValue(dpiEnqOptions *options, dpiError error; int status; - if (dpiGen__startPublicFn(options, DPI_HTYPE_ENQ_OPTIONS, fnName, 1, + if (dpiGen__startPublicFn(options, DPI_HTYPE_ENQ_OPTIONS, fnName, &error) < 0) return dpiGen__endPublicFn(options, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(options, value) @@ -171,4 +171,3 @@ int dpiEnqOptions_setVisibility(dpiEnqOptions *options, dpiVisibility value) return dpiEnqOptions__setAttrValue(options, DPI_OCI_ATTR_VISIBILITY, __func__, &value, 0); } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiEnv.c b/vendor/github.com/godror/godror/odpi/src/dpiEnv.c similarity index 68% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiEnv.c rename to vendor/github.com/godror/godror/odpi/src/dpiEnv.c index e7dff7730a2..c1a2c3f7d61 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiEnv.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiEnv.c @@ -24,7 +24,7 @@ void dpiEnv__free(dpiEnv *env, dpiError *error) { if (env->threaded) dpiMutex__destroy(env->mutex); - if (env->handle) { + if (env->handle && !env->externalHandle) { dpiOci__handleFree(env->handle, DPI_OCI_HTYPE_ENV); env->handle = NULL; } @@ -67,52 +67,68 @@ int dpiEnv__getEncodingInfo(dpiEnv *env, dpiEncodingInfo *info) //----------------------------------------------------------------------------- // dpiEnv__init() [INTERNAL] -// Initialize the environment structure by creating the OCI environment and -// populating information about the environment. +// Initialize the environment structure. If an external handle is provided it +// is used directly; otherwise, a new OCI environment handle is created. In +// either case, information about the environment is stored for later use. //----------------------------------------------------------------------------- int dpiEnv__init(dpiEnv *env, const dpiContext *context, - const dpiCommonCreateParams *params, dpiError *error) + const dpiCommonCreateParams *params, void *externalHandle, + dpiError *error) { char timezoneBuffer[20]; size_t timezoneLength; - // lookup encoding - if (params->encoding && dpiGlobal__lookupCharSet(params->encoding, - &env->charsetId, error) < 0) - return DPI_FAILURE; + // store context and version information + env->context = context; + env->versionInfo = context->versionInfo; - // check for identical encoding before performing lookup - if (params->nencoding && params->encoding && - strcmp(params->nencoding, params->encoding) == 0) - env->ncharsetId = env->charsetId; - else if (params->nencoding && dpiGlobal__lookupCharSet(params->nencoding, - &env->ncharsetId, error) < 0) - return DPI_FAILURE; + // an external handle is available, use it directly + if (externalHandle) { + env->handle = externalHandle; + env->externalHandle = 1; - // both charsetId and ncharsetId must be zero or both must be non-zero - // use NLS routine to look up missing value, if needed - if (env->charsetId && !env->ncharsetId) { - if (dpiOci__nlsEnvironmentVariableGet(DPI_OCI_NLS_NCHARSET_ID, - &env->ncharsetId, error) < 0) - return DPI_FAILURE; - } else if (!env->charsetId && env->ncharsetId) { - if (dpiOci__nlsEnvironmentVariableGet(DPI_OCI_NLS_CHARSET_ID, + // otherwise, lookup encodings + } else { + + // lookup encoding + if (params->encoding && dpiGlobal__lookupCharSet(params->encoding, &env->charsetId, error) < 0) return DPI_FAILURE; - } - // create the new environment handle - env->context = context; - env->versionInfo = context->versionInfo; - if (dpiOci__envNlsCreate(&env->handle, params->createMode | DPI_OCI_OBJECT, - env->charsetId, env->ncharsetId, error) < 0) - return DPI_FAILURE; + // check for identical encoding before performing lookup of national + // character set encoding + if (params->nencoding && params->encoding && + strcmp(params->nencoding, params->encoding) == 0) + env->ncharsetId = env->charsetId; + else if (params->nencoding && + dpiGlobal__lookupCharSet(params->nencoding, + &env->ncharsetId, error) < 0) + return DPI_FAILURE; + + // both charsetId and ncharsetId must be zero or both must be non-zero + // use NLS routine to look up missing value, if needed + if (env->charsetId && !env->ncharsetId) { + if (dpiOci__nlsEnvironmentVariableGet(DPI_OCI_NLS_NCHARSET_ID, + &env->ncharsetId, error) < 0) + return DPI_FAILURE; + } else if (!env->charsetId && env->ncharsetId) { + if (dpiOci__nlsEnvironmentVariableGet(DPI_OCI_NLS_CHARSET_ID, + &env->charsetId, error) < 0) + return DPI_FAILURE; + } + + // create new environment handle + if (dpiOci__envNlsCreate(&env->handle, + params->createMode | DPI_OCI_OBJECT, + env->charsetId, env->ncharsetId, error) < 0) + return DPI_FAILURE; + + } - // create the error handle pool and acquire the first error handle + // create the error handle pool if (dpiHandlePool__create(&env->errorHandles, error) < 0) return DPI_FAILURE; - if (dpiEnv__initError(env, error) < 0) - return DPI_FAILURE; + error->env = env; // if threaded, create mutex for reference counts if (params->createMode & DPI_OCI_THREADED) @@ -162,28 +178,3 @@ int dpiEnv__init(dpiEnv *env, const dpiContext *context, return DPI_SUCCESS; } - - -//----------------------------------------------------------------------------- -// dpiEnv__initError() [INTERNAL] -// Retrieve the OCI error handle to use for error handling, from a pool of -// error handles common to the environment handle. The environment that was -// used to create the error handle is stored in the error structure so that -// the encoding and character set can be retrieved in the event of an OCI -// error (which uses the CHAR encoding of the environment). -//----------------------------------------------------------------------------- -int dpiEnv__initError(dpiEnv *env, dpiError *error) -{ - error->env = env; - if (dpiHandlePool__acquire(env->errorHandles, &error->handle, error) < 0) - return DPI_FAILURE; - - if (!error->handle) { - if (dpiOci__handleAlloc(env->handle, &error->handle, - DPI_OCI_HTYPE_ERROR, "allocate OCI error", error) < 0) - return DPI_FAILURE; - } - - return DPI_SUCCESS; -} - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiError.c b/vendor/github.com/godror/godror/odpi/src/dpiError.c similarity index 85% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiError.c rename to vendor/github.com/godror/godror/odpi/src/dpiError.c index c76070562cb..aac57b92f18 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiError.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiError.c @@ -1,5 +1,5 @@ //----------------------------------------------------------------------------- -// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. // This program is free software: you can modify it and/or redistribute it // under the terms of: // @@ -18,21 +18,125 @@ #include "dpiErrorMessages.h" //----------------------------------------------------------------------------- -// dpiError__check() [INTERNAL] -// Checks to see if the status of the last call resulted in an error -// condition. If so, the error is populated. Note that trailing newlines and -// spaces are truncated from the message if they exist. If the connection is -// not NULL a check is made to see if the connection is no longer viable. +// dpiError__getInfo() [INTERNAL] +// Get the error state from the error structure. Returns DPI_FAILURE as a +// convenience to the caller. +//----------------------------------------------------------------------------- +int dpiError__getInfo(dpiError *error, dpiErrorInfo *info) +{ + if (!info) + return DPI_FAILURE; + info->code = error->buffer->code; + info->offset = error->buffer->offset; + info->message = error->buffer->message; + info->messageLength = error->buffer->messageLength; + info->fnName = error->buffer->fnName; + info->action = error->buffer->action; + info->isRecoverable = error->buffer->isRecoverable; + info->encoding = error->buffer->encoding; + switch(info->code) { + case 12154: // TNS:could not resolve the connect identifier specified + info->sqlState = "42S02"; + break; + case 22: // invalid session ID; access denied + case 378: // buffer pools cannot be created as specified + case 602: // Internal programming exception + case 603: // ORACLE server session terminated by fatal error + case 604: // error occurred at recursive SQL level + case 609: // could not attach to incoming connection + case 1012: // not logged on + case 1033: // ORACLE initialization or shutdown in progress + case 1041: // internal error. hostdef extension doesn't exist + case 1043: // user side memory corruption + case 1089: // immediate shutdown or close in progress + case 1090: // shutdown in progress + case 1092: // ORACLE instance terminated. Disconnection forced + case 3113: // end-of-file on communication channel + case 3114: // not connected to ORACLE + case 3122: // attempt to close ORACLE-side window on user side + case 3135: // connection lost contact + case 12153: // TNS:not connected + case 27146: // post/wait initialization failed + case 28511: // lost RPC connection to heterogeneous remote agent + info->sqlState = "01002"; + break; + default: + if (error->buffer->code == 0 && + error->buffer->errorNum == (dpiErrorNum) 0) + info->sqlState = "00000"; + else info->sqlState = "HY000"; + break; + } + return DPI_FAILURE; +} + + +//----------------------------------------------------------------------------- +// dpiError__initHandle() [INTERNAL] +// Retrieve the OCI error handle to use for error handling, from a pool of +// error handles common to the environment handle stored on the error. This +// environment also controls the encoding of OCI errors (which uses the CHAR +// encoding of the environment). +//----------------------------------------------------------------------------- +int dpiError__initHandle(dpiError *error) +{ + if (dpiHandlePool__acquire(error->env->errorHandles, &error->handle, + error) < 0) + return DPI_FAILURE; + if (!error->handle) { + if (dpiOci__handleAlloc(error->env->handle, &error->handle, + DPI_OCI_HTYPE_ERROR, "allocate OCI error", error) < 0) + return DPI_FAILURE; + } + return DPI_SUCCESS; +} + + +//----------------------------------------------------------------------------- +// dpiError__set() [INTERNAL] +// Set the error buffer to the specified DPI error. Returns DPI_FAILURE as a +// convenience to the caller. +//----------------------------------------------------------------------------- +int dpiError__set(dpiError *error, const char *action, dpiErrorNum errorNum, + ...) +{ + va_list varArgs; + + if (error) { + error->buffer->code = 0; + error->buffer->isRecoverable = 0; + error->buffer->offset = 0; + strcpy(error->buffer->encoding, DPI_CHARSET_NAME_UTF8); + error->buffer->action = action; + error->buffer->errorNum = errorNum; + va_start(varArgs, errorNum); + error->buffer->messageLength = + (uint32_t) vsnprintf(error->buffer->message, + sizeof(error->buffer->message), + dpiErrorMessages[errorNum - DPI_ERR_NO_ERR], varArgs); + va_end(varArgs); + if (dpiDebugLevel & DPI_DEBUG_LEVEL_ERRORS) + dpiDebug__print("internal error %.*s (%s / %s)\n", + error->buffer->messageLength, error->buffer->message, + error->buffer->fnName, action); + } + return DPI_FAILURE; +} + + +//----------------------------------------------------------------------------- +// dpiError__setFromOCI() [INTERNAL] +// Called when an OCI error has occurred and sets the error structure with +// the contents of that error. Note that trailing newlines and spaces are +// truncated from the message if they exist. If the connection is not NULL a +// check is made to see if the connection is no longer viable. The value +// DPI_FAILURE is returned as a convenience to the caller. //----------------------------------------------------------------------------- -int dpiError__check(dpiError *error, int status, dpiConn *conn, +int dpiError__setFromOCI(dpiError *error, int status, dpiConn *conn, const char *action) { uint32_t callTimeout; - // no error has taken place - if (status == DPI_OCI_SUCCESS || status == DPI_OCI_SUCCESS_WITH_INFO) - return DPI_SUCCESS; - // special error cases if (status == DPI_OCI_INVALID_HANDLE) return dpiError__set(error, action, DPI_ERR_INVALID_HANDLE, "OCI"); @@ -98,6 +202,7 @@ int dpiError__check(dpiError *error, int status, dpiConn *conn, conn->deadSession = 1; break; case 3136: // inbound connection timed out + case 3156: // OCI call timed out case 12161: // TNS:internal error: partial data received callTimeout = 0; if (conn->env->versionInfo->versionNum >= 18) @@ -115,90 +220,3 @@ int dpiError__check(dpiError *error, int status, dpiConn *conn, return DPI_FAILURE; } - - -//----------------------------------------------------------------------------- -// dpiError__getInfo() [INTERNAL] -// Get the error state from the error structure. Returns DPI_FAILURE as a -// convenience to the caller. -//----------------------------------------------------------------------------- -int dpiError__getInfo(dpiError *error, dpiErrorInfo *info) -{ - if (!info) - return DPI_FAILURE; - info->code = error->buffer->code; - info->offset = error->buffer->offset; - info->message = error->buffer->message; - info->messageLength = error->buffer->messageLength; - info->fnName = error->buffer->fnName; - info->action = error->buffer->action; - info->isRecoverable = error->buffer->isRecoverable; - info->encoding = error->buffer->encoding; - switch(info->code) { - case 12154: // TNS:could not resolve the connect identifier specified - info->sqlState = "42S02"; - break; - case 22: // invalid session ID; access denied - case 378: // buffer pools cannot be created as specified - case 602: // Internal programming exception - case 603: // ORACLE server session terminated by fatal error - case 604: // error occurred at recursive SQL level - case 609: // could not attach to incoming connection - case 1012: // not logged on - case 1033: // ORACLE initialization or shutdown in progress - case 1041: // internal error. hostdef extension doesn't exist - case 1043: // user side memory corruption - case 1089: // immediate shutdown or close in progress - case 1090: // shutdown in progress - case 1092: // ORACLE instance terminated. Disconnection forced - case 3113: // end-of-file on communication channel - case 3114: // not connected to ORACLE - case 3122: // attempt to close ORACLE-side window on user side - case 3135: // connection lost contact - case 12153: // TNS:not connected - case 27146: // post/wait initialization failed - case 28511: // lost RPC connection to heterogeneous remote agent - info->sqlState = "01002"; - break; - default: - if (error->buffer->code == 0 && - error->buffer->errorNum == (dpiErrorNum) 0) - info->sqlState = "00000"; - else info->sqlState = "HY000"; - break; - } - return DPI_FAILURE; -} - - -//----------------------------------------------------------------------------- -// dpiError__set() [INTERNAL] -// Set the error buffer to the specified DPI error. Returns DPI_FAILURE as a -// convenience to the caller. -//----------------------------------------------------------------------------- -int dpiError__set(dpiError *error, const char *action, dpiErrorNum errorNum, - ...) -{ - va_list varArgs; - - if (error) { - error->buffer->code = 0; - error->buffer->isRecoverable = 0; - error->buffer->offset = 0; - strcpy(error->buffer->encoding, DPI_CHARSET_NAME_UTF8); - error->buffer->action = action; - error->buffer->errorNum = errorNum; - va_start(varArgs, errorNum); - error->buffer->messageLength = - (uint32_t) vsnprintf(error->buffer->message, - sizeof(error->buffer->message), - dpiErrorMessages[errorNum - DPI_ERR_NO_ERR], varArgs); - va_end(varArgs); - if (dpiDebugLevel & DPI_DEBUG_LEVEL_ERRORS) - dpiDebug__print("internal error %.*s (%s / %s)\n", - error->buffer->messageLength, error->buffer->message, - error->buffer->fnName, action); - } - return DPI_FAILURE; -} - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiErrorMessages.h b/vendor/github.com/godror/godror/odpi/src/dpiErrorMessages.h similarity index 94% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiErrorMessages.h rename to vendor/github.com/godror/godror/odpi/src/dpiErrorMessages.h index fd87de21279..1de52a2b17b 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiErrorMessages.h +++ b/vendor/github.com/godror/godror/odpi/src/dpiErrorMessages.h @@ -83,5 +83,8 @@ static const char* const dpiErrorMessages[DPI_ERR_MAX - DPI_ERR_NO_ERR] = { "DPI-1067: call timeout of %u ms exceeded with ORA-%d", // DPI_ERR_CALL_TIMEOUT "DPI-1068: SODA cursor was already closed", // DPI_ERR_SODA_CURSOR_CLOSED "DPI-1069: proxy user name must be enclosed in [] when using external authentication", // DPI_ERR_EXT_AUTH_INVALID_PROXY + "DPI-1070: no payload provided in message properties", // DPI_ERR_QUEUE_NO_PAYLOAD + "DPI-1071: payload type in message properties must match the payload type of the queue", // DPI_ERR_QUEUE_WRONG_PAYLOAD_TYPE + "DPI-1072: the Oracle Client library version is unsupported", // DPI_ERR_ORACLE_CLIENT_UNSUPPORTED + "DPI-1073: sharding key is required when specifying a super sharding key", // DPI_ERR_MISSING_SHARDING_KEY }; - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiGen.c b/vendor/github.com/godror/godror/odpi/src/dpiGen.c similarity index 95% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiGen.c rename to vendor/github.com/godror/godror/odpi/src/dpiGen.c index e6b65b9a65b..f671adf2a21 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiGen.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiGen.c @@ -133,6 +133,12 @@ static const dpiTypeDef dpiAllTypeDefs[DPI_HTYPE_MAX - DPI_HTYPE_NONE - 1] = { sizeof(dpiSodaDocCursor), // size of structure 0x80ceb83b, // check integer (dpiTypeFreeProc) dpiSodaDocCursor__free + }, + { + "dpiQueue", // name + sizeof(dpiQueue), // size of structure + 0x54904ba2, // check integer + (dpiTypeFreeProc) dpiQueue__free } }; @@ -145,7 +151,7 @@ int dpiGen__addRef(void *ptr, dpiHandleTypeNum typeNum, const char *fnName) { dpiError error; - if (dpiGen__startPublicFn(ptr, typeNum, fnName, 0, &error) < 0) + if (dpiGen__startPublicFn(ptr, typeNum, fnName, &error) < 0) return dpiGen__endPublicFn(ptr, DPI_FAILURE, &error); dpiGen__setRefCount(ptr, &error, 1); return dpiGen__endPublicFn(ptr, DPI_SUCCESS, &error); @@ -218,7 +224,7 @@ int dpiGen__endPublicFn(const void *ptr, int returnValue, dpiError *error) dpiDebug__print("fn end %s(%p) -> %d\n", error->buffer->fnName, ptr, returnValue); if (error->handle) - dpiHandlePool__release(error->env->errorHandles, error->handle, error); + dpiHandlePool__release(error->env->errorHandles, &error->handle); return returnValue; } @@ -235,7 +241,7 @@ int dpiGen__release(void *ptr, dpiHandleTypeNum typeNum, const char *fnName) { dpiError error; - if (dpiGen__startPublicFn(ptr, typeNum, fnName, 1, &error) < 0) + if (dpiGen__startPublicFn(ptr, typeNum, fnName, &error) < 0) return dpiGen__endPublicFn(ptr, DPI_FAILURE, &error); dpiGen__setRefCount(ptr, &error, -1); return dpiGen__endPublicFn(ptr, DPI_SUCCESS, &error); @@ -286,7 +292,7 @@ void dpiGen__setRefCount(void *ptr, dpiError *error, int increment) // all subsequent calls. //----------------------------------------------------------------------------- int dpiGen__startPublicFn(const void *ptr, dpiHandleTypeNum typeNum, - const char *fnName, int needErrorHandle, dpiError *error) + const char *fnName, dpiError *error) { dpiBaseType *value = (dpiBaseType*) ptr; @@ -296,8 +302,6 @@ int dpiGen__startPublicFn(const void *ptr, dpiHandleTypeNum typeNum, return DPI_FAILURE; if (dpiGen__checkHandle(ptr, typeNum, "check main handle", error) < 0) return DPI_FAILURE; - if (needErrorHandle && dpiEnv__initError(value->env, error) < 0) - return DPI_FAILURE; + error->env = value->env; return DPI_SUCCESS; } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiGlobal.c b/vendor/github.com/godror/godror/odpi/src/dpiGlobal.c similarity index 99% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiGlobal.c rename to vendor/github.com/godror/godror/odpi/src/dpiGlobal.c index c57dd557848..6599d870421 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiGlobal.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiGlobal.c @@ -289,4 +289,3 @@ int dpiGlobal__lookupEncoding(uint16_t charsetId, char *encoding, return DPI_SUCCESS; } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiHandleList.c b/vendor/github.com/godror/godror/odpi/src/dpiHandleList.c similarity index 98% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiHandleList.c rename to vendor/github.com/godror/godror/odpi/src/dpiHandleList.c index 920a2c628fe..2f3864067bb 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiHandleList.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiHandleList.c @@ -43,7 +43,7 @@ int dpiHandleList__addHandle(dpiHandleList *list, void *handle, list->handles = tempHandles; list->numSlots = numSlots; *slotNum = list->numUsedSlots++; - list->currentPos = list->numUsedSlots + 1; + list->currentPos = list->numUsedSlots; } else { for (i = 0; i < list->numSlots; i++) { if (!list->handles[list->currentPos]) @@ -114,4 +114,3 @@ void dpiHandleList__removeHandle(dpiHandleList *list, uint32_t slotNum) list->numUsedSlots--; dpiMutex__release(list->mutex); } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiHandlePool.c b/vendor/github.com/godror/godror/odpi/src/dpiHandlePool.c similarity index 94% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiHandlePool.c rename to vendor/github.com/godror/godror/odpi/src/dpiHandlePool.c index aab33c86f2f..456f094f136 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiHandlePool.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiHandlePool.c @@ -105,14 +105,15 @@ void dpiHandlePool__free(dpiHandlePool *pool) // dpiHandlePool__release() [INTERNAL] // Release a handle back to the pool. No checks are performed on the handle // that is being returned to the pool; It will simply be placed back in the -// pool. +// pool. The handle is then NULLed in order to avoid multiple attempts to +// release the handle back to the pool. //----------------------------------------------------------------------------- -void dpiHandlePool__release(dpiHandlePool *pool, void *handle, dpiError *error) +void dpiHandlePool__release(dpiHandlePool *pool, void **handle) { dpiMutex__acquire(pool->mutex); - pool->handles[pool->releasePos++] = handle; + pool->handles[pool->releasePos++] = *handle; + *handle = NULL; if (pool->releasePos == pool->numSlots) pool->releasePos = 0; dpiMutex__release(pool->mutex); } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiImpl.h b/vendor/github.com/godror/godror/odpi/src/dpiImpl.h similarity index 92% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiImpl.h rename to vendor/github.com/godror/godror/odpi/src/dpiImpl.h index 101846dc1da..ec2ede13955 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiImpl.h +++ b/vendor/github.com/godror/godror/odpi/src/dpiImpl.h @@ -153,6 +153,7 @@ extern unsigned long dpiDebugLevel; // define values used for getting/setting OCI attributes #define DPI_OCI_ATTR_DATA_SIZE 1 #define DPI_OCI_ATTR_DATA_TYPE 2 +#define DPI_OCI_ATTR_ENV 5 #define DPI_OCI_ATTR_PRECISION 5 #define DPI_OCI_ATTR_SCALE 6 #define DPI_OCI_ATTR_NAME 4 @@ -165,6 +166,7 @@ extern unsigned long dpiDebugLevel; #define DPI_OCI_ATTR_ROW_COUNT 9 #define DPI_OCI_ATTR_PREFETCH_ROWS 11 #define DPI_OCI_ATTR_PARAM_COUNT 18 +#define DPI_OCI_ATTR_ROWID 19 #define DPI_OCI_ATTR_USERNAME 22 #define DPI_OCI_ATTR_PASSWORD 23 #define DPI_OCI_ATTR_STMT_TYPE 24 @@ -219,6 +221,7 @@ extern unsigned long dpiDebugLevel; #define DPI_OCI_ATTR_NUM_TYPE_ATTRS 228 #define DPI_OCI_ATTR_SUBSCR_CQ_QOSFLAGS 229 #define DPI_OCI_ATTR_LIST_TYPE_ATTRS 229 +#define DPI_OCI_ATTR_SUBSCR_CQ_REGID 230 #define DPI_OCI_ATTR_SUBSCR_NTFN_GROUPING_CLASS 231 #define DPI_OCI_ATTR_SUBSCR_NTFN_GROUPING_VALUE 232 #define DPI_OCI_ATTR_SUBSCR_NTFN_GROUPING_TYPE 233 @@ -263,6 +266,7 @@ extern unsigned long dpiDebugLevel; #define DPI_OCI_ATTR_CONNECTION_CLASS 425 #define DPI_OCI_ATTR_PURITY 426 #define DPI_OCI_ATTR_RECEIVE_TIMEOUT 436 +#define DPI_OCI_ATTR_LOBPREFETCH_LENGTH 440 #define DPI_OCI_ATTR_SUBSCR_IPADDR 452 #define DPI_OCI_ATTR_UB8_ROW_COUNT 457 #define DPI_OCI_ATTR_SPOOL_AUTH 460 @@ -294,6 +298,7 @@ extern unsigned long dpiDebugLevel; #define DPI_OCI_ATTR_SODA_SKIP 577 #define DPI_OCI_ATTR_SODA_LIMIT 578 #define DPI_OCI_ATTR_SODA_DOC_COUNT 593 +#define DPI_OCI_ATTR_SPOOL_MAX_PER_SHARD 602 // define OCI object type constants #define DPI_OCI_OTYPE_NAME 1 @@ -335,6 +340,11 @@ extern unsigned long dpiDebugLevel; #define DPI_OCI_TYPECODE_SMALLINT 246 #define DPI_SQLT_REC 250 #define DPI_SQLT_BOL 252 +#define DPI_OCI_TYPECODE_ROWID 262 +#define DPI_OCI_TYPECODE_LONG 263 +#define DPI_OCI_TYPECODE_LONG_RAW 264 +#define DPI_OCI_TYPECODE_BINARY_INTEGER 265 +#define DPI_OCI_TYPECODE_PLS_INTEGER 266 // define session pool constants #define DPI_OCI_SPD_FORCE 0x0001 @@ -428,6 +438,7 @@ extern unsigned long dpiDebugLevel; #define DPI_OCI_SODA_COLL_CREATE_MAP 0x00010000 #define DPI_OCI_SODA_INDEX_DROP_FORCE 0x00010000 #define DPI_OCI_TRANS_TWOPHASE 0x01000000 +#define DPI_OCI_SECURE_NOTIFICATION 0x20000000 //----------------------------------------------------------------------------- // Macros @@ -519,6 +530,10 @@ typedef enum { DPI_ERR_CALL_TIMEOUT, DPI_ERR_SODA_CURSOR_CLOSED, DPI_ERR_EXT_AUTH_INVALID_PROXY, + DPI_ERR_QUEUE_NO_PAYLOAD, + DPI_ERR_QUEUE_WRONG_PAYLOAD_TYPE, + DPI_ERR_ORACLE_CLIENT_UNSUPPORTED, + DPI_ERR_MISSING_SHARDING_KEY, DPI_ERR_MAX } dpiErrorNum; @@ -544,6 +559,7 @@ typedef enum { DPI_HTYPE_SODA_DB, DPI_HTYPE_SODA_DOC, DPI_HTYPE_SODA_DOC_CURSOR, + DPI_HTYPE_QUEUE, DPI_HTYPE_MAX } dpiHandleTypeNum; @@ -587,6 +603,25 @@ typedef struct { uint32_t maxLifetimeSession; } dpiPoolCreateParams__v30; +// structure used for creating pools (3.2) +typedef struct { + uint32_t minSessions; + uint32_t maxSessions; + uint32_t sessionIncrement; + int pingInterval; + int pingTimeout; + int homogeneous; + int externalAuth; + dpiPoolGetMode getMode; + const char *outPoolName; + uint32_t outPoolNameLength; + uint32_t timeout; + uint32_t waitTimeout; + uint32_t maxLifetimeSession; + const char *plsqlFixupCallback; + uint32_t plsqlFixupCallbackLength; +} dpiPoolCreateParams__v32; + // structure used for creating connections (3.0) typedef struct { dpiAuthMode authMode; @@ -612,6 +647,49 @@ typedef struct { uint8_t numSuperShardingKeyColumns; } dpiConnCreateParams__v30; +// structure used for creating subscriptions (3.0 and 3.1) +typedef struct { + dpiSubscrNamespace subscrNamespace; + dpiSubscrProtocol protocol; + dpiSubscrQOS qos; + dpiOpCode operations; + uint32_t portNumber; + uint32_t timeout; + const char *name; + uint32_t nameLength; + dpiSubscrCallback callback; + void *callbackContext; + const char *recipientName; + uint32_t recipientNameLength; + const char *ipAddress; + uint32_t ipAddressLength; + uint8_t groupingClass; + uint32_t groupingValue; + uint8_t groupingType; +} dpiSubscrCreateParams__v30; + +// structure used for creating subscriptions (3.2) +typedef struct { + dpiSubscrNamespace subscrNamespace; + dpiSubscrProtocol protocol; + dpiSubscrQOS qos; + dpiOpCode operations; + uint32_t portNumber; + uint32_t timeout; + const char *name; + uint32_t nameLength; + dpiSubscrCallback callback; + void *callbackContext; + const char *recipientName; + uint32_t recipientNameLength; + const char *ipAddress; + uint32_t ipAddressLength; + uint8_t groupingClass; + uint32_t groupingValue; + uint8_t groupingType; + uint64_t outRegId; +} dpiSubscrCreateParams__v32; + //----------------------------------------------------------------------------- // OCI type definitions @@ -632,6 +710,17 @@ typedef struct { uint8_t second; } dpiOciDate; +// alternative representation of OCI Date type used for sharding +typedef struct { + uint8_t century; + uint8_t year; + uint8_t month; + uint8_t day; + uint8_t hour; + uint8_t minute; + uint8_t second; +} dpiShardingOciDate; + // representation of OCI XID type (two-phase commit) typedef struct { long formatID; @@ -707,6 +796,7 @@ typedef struct { void *baseDate; // midnight, January 1, 1970 int threaded; // threaded mode enabled? int events; // events mode enabled? + int externalHandle; // external handle? } dpiEnv; // used to manage all errors that take place in the library; the implementation @@ -816,6 +906,7 @@ typedef union { char *asBytes; float *asFloat; double *asDouble; + int32_t *asInt32; int64_t *asInt64; uint64_t *asUint64; dpiOciNumber *asNumber; @@ -836,6 +927,7 @@ typedef union { // buffers to Oracle when values are being transferred to or from the Oracle // database typedef union { + int32_t asInt32; int64_t asInt64; uint64_t asUint64; float asFloat; @@ -869,6 +961,18 @@ typedef struct { dpiOracleData data; // Oracle data buffers (internal only) } dpiVarBuffer; +// represents memory areas used for enqueuing and dequeuing messages from +// queues +typedef struct { + uint32_t numElements; // number of elements in next arrays + dpiMsgProps **props; // array of dpiMsgProps handles + void **handles; // array of OCI msg prop handles + void **instances; // array of instances + void **indicators; // array of indicators + int16_t *rawIndicators; // array of indicators (RAW queues) + void **msgIds; // array of OCI message ids +} dpiQueueBuffer; + //----------------------------------------------------------------------------- // External implementation type definitions @@ -900,8 +1004,11 @@ struct dpiConn { void *handle; // OCI service context handle void *serverHandle; // OCI server handle void *sessionHandle; // OCI session handle + void *shardingKey; // OCI sharding key descriptor + void *superShardingKey; // OCI supper sharding key descriptor const char *releaseString; // cached release string or NULL uint32_t releaseStringLength; // cached release string length or 0 + void *rawTDO; // cached RAW TDO dpiVersionInfo versionInfo; // Oracle database version info uint32_t commitMode; // commit mode (for two-phase commits) uint16_t charsetId; // database character set ID @@ -932,6 +1039,7 @@ struct dpiStmt { dpiConn *conn; // connection which created this uint32_t openSlotNum; // slot in connection handle list void *handle; // OCI statement handle + dpiStmt *parentStmt; // parent statement (implicit results) uint32_t fetchArraySize; // rows to fetch each time uint32_t bufferRowCount; // number of rows in fetch buffers uint32_t bufferRowIndex; // index into buffers for current row @@ -946,6 +1054,7 @@ struct dpiStmt { uint64_t rowCount; // rows affected or rows fetched so far uint64_t bufferMinRow; // row num of first row in buffers uint16_t statementType; // type of statement + dpiRowid *lastRowid; // rowid of last affected row int isOwned; // owned by structure? int hasRowsToFetch; // potentially more rows to fetch? int scrollable; // scrollable cursor? @@ -1047,10 +1156,12 @@ struct dpiSubscr { dpiType_HEAD dpiConn *conn; // connection which created this void *handle; // OCI subscription handle + dpiMutexType mutex; // enables thread safety dpiSubscrNamespace subscrNamespace; // OCI namespace dpiSubscrQOS qos; // quality of service flags dpiSubscrCallback callback; // callback when event is propagated void *callbackContext; // context pointer for callback + int clientInitiated; // client initiated? int registered; // registered with database? }; @@ -1072,15 +1183,16 @@ struct dpiEnqOptions { void *handle; // OCI enqueue options handle }; -// represents the available properties for message when using advanced queuing +// represents the available properties for messages when using advanced queuing // and is exposed publicly as a handle of type DPI_HTYPE_MSG_PROPS; the // implementation for this is found in the file dpiMsgProps.c struct dpiMsgProps { dpiType_HEAD dpiConn *conn; // connection which created this void *handle; // OCI message properties handle - char *buffer; // latest message ID en/dequeued - uint32_t bufferLength; // size of allocated buffer + dpiObject *payloadObj; // payload (object) + void *payloadRaw; // payload (RAW) + void *msgIdRaw; // message ID (RAW) }; // represents SODA collections and is exposed publicly as a handle of type @@ -1129,6 +1241,19 @@ struct dpiSodaDocCursor { void *handle; // OCI SODA document cursor handle }; +// represents a queue used in AQ (advanced queuing) and is exposed publicly as +// a handle of type DPI_HTYPE_QUEUE; the implementation for this is found in +// the file dpiQueue.c +struct dpiQueue { + dpiType_HEAD + dpiConn *conn; // connection which created this + const char *name; // name of the queue (NULL-terminated) + dpiObjectType *payloadType; // object type (for object payloads) + dpiDeqOptions *deqOptions; // dequeue options + dpiEnqOptions *enqOptions; // enqueue options + dpiQueueBuffer buffer; // buffer area +}; + //----------------------------------------------------------------------------- // definition of internal dpiContext methods @@ -1145,6 +1270,8 @@ void dpiContext__initSubscrCreateParams(dpiSubscrCreateParams *params); //----------------------------------------------------------------------------- int dpiDataBuffer__fromOracleDate(dpiDataBuffer *data, dpiOciDate *oracleValue); +int dpiDataBuffer__fromOracleDateAsDouble(dpiDataBuffer *data, + dpiEnv *env, dpiError *error, dpiOciDate *oracleValue); int dpiDataBuffer__fromOracleIntervalDS(dpiDataBuffer *data, dpiEnv *env, dpiError *error, void *oracleValue); int dpiDataBuffer__fromOracleIntervalYM(dpiDataBuffer *data, dpiEnv *env, @@ -1162,6 +1289,8 @@ int dpiDataBuffer__fromOracleTimestamp(dpiDataBuffer *data, dpiEnv *env, int dpiDataBuffer__fromOracleTimestampAsDouble(dpiDataBuffer *data, dpiEnv *env, dpiError *error, void *oracleValue); int dpiDataBuffer__toOracleDate(dpiDataBuffer *data, dpiOciDate *oracleValue); +int dpiDataBuffer__toOracleDateFromDouble(dpiDataBuffer *data, dpiEnv *env, + dpiError *error, dpiOciDate *oracleValue); int dpiDataBuffer__toOracleIntervalDS(dpiDataBuffer *data, dpiEnv *env, dpiError *error, void *oracleValue); int dpiDataBuffer__toOracleIntervalYM(dpiDataBuffer *data, dpiEnv *env, @@ -1185,19 +1314,20 @@ int dpiDataBuffer__toOracleTimestampFromDouble(dpiDataBuffer *data, //----------------------------------------------------------------------------- void dpiEnv__free(dpiEnv *env, dpiError *error); int dpiEnv__init(dpiEnv *env, const dpiContext *context, - const dpiCommonCreateParams *params, dpiError *error); + const dpiCommonCreateParams *params, void *externalHandle, + dpiError *error); int dpiEnv__getEncodingInfo(dpiEnv *env, dpiEncodingInfo *info); -int dpiEnv__initError(dpiEnv *env, dpiError *error); //----------------------------------------------------------------------------- // definition of internal dpiError methods //----------------------------------------------------------------------------- -int dpiError__check(dpiError *error, int status, dpiConn *conn, - const char *action); int dpiError__getInfo(dpiError *error, dpiErrorInfo *info); +int dpiError__initHandle(dpiError *error); int dpiError__set(dpiError *error, const char *context, dpiErrorNum errorNum, ...); +int dpiError__setFromOCI(dpiError *error, int status, dpiConn *conn, + const char *action); //----------------------------------------------------------------------------- @@ -1212,7 +1342,7 @@ int dpiGen__endPublicFn(const void *ptr, int returnValue, dpiError *error); int dpiGen__release(void *ptr, dpiHandleTypeNum typeNum, const char *fnName); void dpiGen__setRefCount(void *ptr, dpiError *error, int increment); int dpiGen__startPublicFn(const void *ptr, dpiHandleTypeNum typeNum, - const char *fnName, int needErrorHandle, dpiError *error); + const char *fnName, dpiError *error); //----------------------------------------------------------------------------- @@ -1245,6 +1375,7 @@ int dpiConn__create(dpiConn *conn, const dpiContext *context, const dpiCommonCreateParams *commonParams, dpiConnCreateParams *createParams, dpiError *error); void dpiConn__free(dpiConn *conn, dpiError *error); +int dpiConn__getRawTDO(dpiConn *conn, dpiError *error); int dpiConn__getServerVersion(dpiConn *conn, dpiError *error); @@ -1408,15 +1539,28 @@ int dpiSodaDocCursor__allocate(dpiSodaColl *coll, void *handle, void dpiSodaDocCursor__free(dpiSodaDocCursor *cursor, dpiError *error); +//----------------------------------------------------------------------------- +// definition of internal dpiQueue methods +//----------------------------------------------------------------------------- +int dpiQueue__allocate(dpiConn *conn, const char *name, uint32_t nameLength, + dpiObjectType *payloadType, dpiQueue **queue, dpiError *error); +void dpiQueue__free(dpiQueue *queue, dpiError *error); + + //----------------------------------------------------------------------------- // definition of internal dpiOci methods //----------------------------------------------------------------------------- int dpiOci__aqDeq(dpiConn *conn, const char *queueName, void *options, void *msgProps, void *payloadType, void **payload, void **payloadInd, void **msgId, dpiError *error); +int dpiOci__aqDeqArray(dpiConn *conn, const char *queueName, void *options, + uint32_t *numIters, void **msgProps, void *payloadType, void **payload, void **payloadInd, void **msgId, dpiError *error); int dpiOci__aqEnq(dpiConn *conn, const char *queueName, void *options, void *msgProps, void *payloadType, void **payload, void **payloadInd, void **msgId, dpiError *error); +int dpiOci__aqEnqArray(dpiConn *conn, const char *queueName, void *options, + uint32_t *numIters, void **msgProps, void *payloadType, void **payload, + void **payloadInd, void **msgId, dpiError *error); int dpiOci__arrayDescriptorAlloc(void *envHandle, void **handle, uint32_t handleType, uint32_t arraySize, dpiError *error); int dpiOci__arrayDescriptorFree(void **handle, uint32_t handleType); @@ -1456,6 +1600,8 @@ int dpiOci__dateTimeConstruct(void *envHandle, void *handle, int16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t fsecond, const char *tz, size_t tzLength, dpiError *error); +int dpiOci__dateTimeConvert(void *envHandle, void *inDate, void *outDate, + dpiError *error); int dpiOci__dateTimeGetDate(void *envHandle, void *handle, int16_t *year, uint8_t *month, uint8_t *day, dpiError *error); int dpiOci__dateTimeGetTime(void *envHandle, void *handle, uint8_t *hour, @@ -1546,7 +1692,8 @@ int dpiOci__numberToInt(void *number, void *value, unsigned int valueLength, int dpiOci__numberToReal(double *value, void *number, dpiError *error); int dpiOci__objectCopy(dpiObject *obj, void *sourceInstance, void *sourceIndicator, dpiError *error); -int dpiOci__objectFree(dpiObject *obj, int checkError, dpiError *error); +int dpiOci__objectFree(void *envHandle, void *data, int checkError, + dpiError *error); int dpiOci__objectGetAttr(dpiObject *obj, dpiObjectAttr *attr, int16_t *scalarValueIndicator, void **valueIndicator, void **value, void **tdo, dpiError *error); @@ -1599,7 +1746,7 @@ int dpiOci__sodaBulkInsert(dpiSodaColl *coll, void **documents, uint32_t numDocuments, void *outputOptions, uint32_t mode, dpiError *error); int dpiOci__sodaBulkInsertAndGet(dpiSodaColl *coll, void **documents, - uint32_t *numDocuments, void *outputOptions, uint32_t mode, + uint32_t numDocuments, void *outputOptions, uint32_t mode, dpiError *error); int dpiOci__sodaCollCreateWithMetadata(dpiSodaDb *db, const char *name, uint32_t nameLength, const char *metadata, uint32_t metadataLength, @@ -1662,7 +1809,7 @@ int dpiOci__stringPtr(void *envHandle, void *handle, char **ptr); int dpiOci__stringResize(void *envHandle, void **handle, uint32_t newSize, dpiError *error); int dpiOci__stringSize(void *envHandle, void *handle, uint32_t *size); -int dpiOci__subscriptionRegister(dpiConn *conn, void **handle, +int dpiOci__subscriptionRegister(dpiConn *conn, void **handle, uint32_t mode, dpiError *error); int dpiOci__subscriptionUnRegister(dpiConn *conn, dpiSubscr *subscr, dpiError *error); @@ -1690,14 +1837,17 @@ int dpiOci__transRollback(dpiConn *conn, int checkError, dpiError *error); int dpiOci__transStart(dpiConn *conn, dpiError *error); int dpiOci__typeByFullName(dpiConn *conn, const char *name, uint32_t nameLength, void **tdo, dpiError *error); +int dpiOci__typeByName(dpiConn *conn, const char *schema, + uint32_t schemaLength, const char *name, uint32_t nameLength, + void **tdo, dpiError *error); //----------------------------------------------------------------------------- // definition of internal dpiMsgProps methods //----------------------------------------------------------------------------- -int dpiMsgProps__create(dpiMsgProps *props, dpiConn *conn, dpiError *error); -int dpiMsgProps__extractMsgId(dpiMsgProps *props, void *ociRaw, - const char **msgId, uint32_t *msgIdLength, dpiError *error); +int dpiMsgProps__allocate(dpiConn *conn, dpiMsgProps **props, dpiError *error); +void dpiMsgProps__extractMsgId(dpiMsgProps *props, const char **msgId, + uint32_t *msgIdLength); void dpiMsgProps__free(dpiMsgProps *props, dpiError *error); @@ -1708,8 +1858,7 @@ int dpiHandlePool__acquire(dpiHandlePool *pool, void **handle, dpiError *error); int dpiHandlePool__create(dpiHandlePool **pool, dpiError *error); void dpiHandlePool__free(dpiHandlePool *pool); -void dpiHandlePool__release(dpiHandlePool *pool, void *handle, - dpiError *error); +void dpiHandlePool__release(dpiHandlePool *pool, void **handle); //----------------------------------------------------------------------------- @@ -1754,4 +1903,3 @@ void dpiDebug__initialize(void); void dpiDebug__print(const char *format, ...); #endif - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiLob.c b/vendor/github.com/godror/godror/odpi/src/dpiLob.c similarity index 94% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiLob.c rename to vendor/github.com/godror/godror/odpi/src/dpiLob.c index 310953fc674..55dfcebad6e 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiLob.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiLob.c @@ -53,10 +53,9 @@ int dpiLob__allocate(dpiConn *conn, const dpiOracleType *type, dpiLob **lob, // dpiLob__check() [INTERNAL] // Check that the LOB is valid and get an error handle for subsequent calls. //----------------------------------------------------------------------------- -static int dpiLob__check(dpiLob *lob, const char *fnName, int needErrorHandle, - dpiError *error) +static int dpiLob__check(dpiLob *lob, const char *fnName, dpiError *error) { - if (dpiGen__startPublicFn(lob, DPI_HTYPE_LOB, fnName, 1, error) < 0) + if (dpiGen__startPublicFn(lob, DPI_HTYPE_LOB, fnName, error) < 0) return DPI_FAILURE; if (!lob->locator) return dpiError__set(error, "check closed", DPI_ERR_LOB_CLOSED); @@ -210,7 +209,7 @@ int dpiLob_close(dpiLob *lob) dpiError error; int status; - if (dpiLob__check(lob, __func__, 1, &error) < 0) + if (dpiLob__check(lob, __func__, &error) < 0) return dpiGen__endPublicFn(lob, DPI_FAILURE, &error); status = dpiLob__close(lob, 1, &error); return dpiGen__endPublicFn(lob, status, &error); @@ -226,7 +225,7 @@ int dpiLob_closeResource(dpiLob *lob) dpiError error; int status; - if (dpiLob__check(lob, __func__, 1, &error) < 0) + if (dpiLob__check(lob, __func__, &error) < 0) return dpiGen__endPublicFn(lob, DPI_FAILURE, &error); status = dpiOci__lobClose(lob, &error); return dpiGen__endPublicFn(lob, status, &error); @@ -242,7 +241,7 @@ int dpiLob_copy(dpiLob *lob, dpiLob **copiedLob) dpiLob *tempLob; dpiError error; - if (dpiLob__check(lob, __func__, 1, &error) < 0) + if (dpiLob__check(lob, __func__, &error) < 0) return dpiGen__endPublicFn(lob, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(lob, copiedLob) if (dpiLob__allocate(lob->conn, lob->type, &tempLob, &error) < 0) @@ -266,7 +265,7 @@ int dpiLob_getBufferSize(dpiLob *lob, uint64_t sizeInChars, { dpiError error; - if (dpiLob__check(lob, __func__, 0, &error) < 0) + if (dpiLob__check(lob, __func__, &error) < 0) return dpiGen__endPublicFn(lob, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(lob, sizeInBytes) if (lob->type->oracleTypeNum == DPI_ORACLE_TYPE_CLOB) @@ -287,7 +286,7 @@ int dpiLob_getChunkSize(dpiLob *lob, uint32_t *size) dpiError error; int status; - if (dpiLob__check(lob, __func__, 0, &error) < 0) + if (dpiLob__check(lob, __func__, &error) < 0) return dpiGen__endPublicFn(lob, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(lob, size) status = dpiOci__lobGetChunkSize(lob, size, &error); @@ -307,7 +306,7 @@ int dpiLob_getDirectoryAndFileName(dpiLob *lob, const char **directoryAlias, dpiError error; // validate parameters - if (dpiLob__check(lob, __func__, 1, &error) < 0) + if (dpiLob__check(lob, __func__, &error) < 0) return dpiGen__endPublicFn(lob, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(lob, directoryAlias) DPI_CHECK_PTR_NOT_NULL(lob, directoryAliasLength) @@ -344,7 +343,7 @@ int dpiLob_getFileExists(dpiLob *lob, int *exists) dpiError error; int status; - if (dpiLob__check(lob, __func__, 1, &error) < 0) + if (dpiLob__check(lob, __func__, &error) < 0) return dpiGen__endPublicFn(lob, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(lob, exists) status = dpiOci__lobFileExists(lob, exists, &error); @@ -361,7 +360,7 @@ int dpiLob_getIsResourceOpen(dpiLob *lob, int *isOpen) dpiError error; int status; - if (dpiLob__check(lob, __func__, 1, &error) < 0) + if (dpiLob__check(lob, __func__, &error) < 0) return dpiGen__endPublicFn(lob, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(lob, isOpen) status = dpiOci__lobIsOpen(lob, isOpen, &error); @@ -378,7 +377,7 @@ int dpiLob_getSize(dpiLob *lob, uint64_t *size) dpiError error; int status; - if (dpiLob__check(lob, __func__, 1, &error) < 0) + if (dpiLob__check(lob, __func__, &error) < 0) return dpiGen__endPublicFn(lob, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(lob, size) status = dpiOci__lobGetLength2(lob, size, &error); @@ -395,7 +394,7 @@ int dpiLob_openResource(dpiLob *lob) dpiError error; int status; - if (dpiLob__check(lob, __func__, 1, &error) < 0) + if (dpiLob__check(lob, __func__, &error) < 0) return dpiGen__endPublicFn(lob, DPI_FAILURE, &error); status = dpiOci__lobOpen(lob, &error); return dpiGen__endPublicFn(lob, status, &error); @@ -412,7 +411,7 @@ int dpiLob_readBytes(dpiLob *lob, uint64_t offset, uint64_t amount, dpiError error; int status; - if (dpiLob__check(lob, __func__, 1, &error) < 0) + if (dpiLob__check(lob, __func__, &error) < 0) return dpiGen__endPublicFn(lob, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(lob, value) DPI_CHECK_PTR_NOT_NULL(lob, valueLength) @@ -443,7 +442,7 @@ int dpiLob_setDirectoryAndFileName(dpiLob *lob, const char *directoryAlias, dpiError error; int status; - if (dpiLob__check(lob, __func__, 1, &error) < 0) + if (dpiLob__check(lob, __func__, &error) < 0) return dpiGen__endPublicFn(lob, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(lob, directoryAlias) DPI_CHECK_PTR_NOT_NULL(lob, fileName) @@ -463,9 +462,9 @@ int dpiLob_setFromBytes(dpiLob *lob, const char *value, uint64_t valueLength) dpiError error; int status; - if (dpiLob__check(lob, __func__, 1, &error) < 0) + if (dpiLob__check(lob, __func__, &error) < 0) return dpiGen__endPublicFn(lob, DPI_FAILURE, &error); - DPI_CHECK_PTR_NOT_NULL(lob, value) + DPI_CHECK_PTR_AND_LENGTH(lob, value) status = dpiLob__setFromBytes(lob, value, valueLength, &error); return dpiGen__endPublicFn(lob, status, &error); } @@ -480,7 +479,7 @@ int dpiLob_trim(dpiLob *lob, uint64_t newSize) dpiError error; int status; - if (dpiLob__check(lob, __func__, 1, &error) < 0) + if (dpiLob__check(lob, __func__, &error) < 0) return dpiGen__endPublicFn(lob, DPI_FAILURE, &error); status = dpiOci__lobTrim2(lob, newSize, &error); return dpiGen__endPublicFn(lob, status, &error); @@ -497,10 +496,9 @@ int dpiLob_writeBytes(dpiLob *lob, uint64_t offset, const char *value, dpiError error; int status; - if (dpiLob__check(lob, __func__, 1, &error) < 0) + if (dpiLob__check(lob, __func__, &error) < 0) return dpiGen__endPublicFn(lob, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(lob, value) status = dpiOci__lobWrite2(lob, offset, value, valueLength, &error); return dpiGen__endPublicFn(lob, status, &error); } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiMsgProps.c b/vendor/github.com/godror/godror/odpi/src/dpiMsgProps.c similarity index 72% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiMsgProps.c rename to vendor/github.com/godror/godror/odpi/src/dpiMsgProps.c index 24260897b19..518d2e7d20b 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiMsgProps.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiMsgProps.c @@ -1,5 +1,5 @@ //----------------------------------------------------------------------------- -// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. // This program is free software: you can modify it and/or redistribute it // under the terms of: // @@ -17,45 +17,40 @@ #include "dpiImpl.h" //----------------------------------------------------------------------------- -// dpiMsgProps__create() [INTERNAL] -// Create a new subscription structure and return it. In case of error NULL -// is returned. +// dpiMsgProps__allocate() [INTERNAL] +// Create a new message properties structure and return it. In case of error +// NULL is returned. //----------------------------------------------------------------------------- -int dpiMsgProps__create(dpiMsgProps *options, dpiConn *conn, dpiError *error) +int dpiMsgProps__allocate(dpiConn *conn, dpiMsgProps **props, dpiError *error) { + dpiMsgProps *tempProps; + + if (dpiGen__allocate(DPI_HTYPE_MSG_PROPS, conn->env, (void**) &tempProps, + error) < 0) + return DPI_FAILURE; dpiGen__setRefCount(conn, error, 1); - options->conn = conn; - return dpiOci__descriptorAlloc(conn->env->handle, &options->handle, - DPI_OCI_DTYPE_AQMSG_PROPERTIES, "allocate descriptor", error); + tempProps->conn = conn; + if (dpiOci__descriptorAlloc(conn->env->handle, &tempProps->handle, + DPI_OCI_DTYPE_AQMSG_PROPERTIES, "allocate descriptor", + error) < 0) { + dpiMsgProps__free(tempProps, error); + return DPI_FAILURE; + } + + *props = tempProps; + return DPI_SUCCESS; } //----------------------------------------------------------------------------- // dpiMsgProps__extractMsgId() [INTERNAL] -// Extract bytes from the OCIRaw value containing the message id and store -// them in allocated memory on the message properties instance. Then resize the -// OCIRaw value so the memory can be reclaimed. +// Extract bytes from the OCIRaw value containing the message id. //----------------------------------------------------------------------------- -int dpiMsgProps__extractMsgId(dpiMsgProps *props, void *ociRaw, - const char **msgId, uint32_t *msgIdLength, dpiError *error) +void dpiMsgProps__extractMsgId(dpiMsgProps *props, const char **msgId, + uint32_t *msgIdLength) { - const char *rawPtr; - - dpiOci__rawPtr(props->env->handle, ociRaw, (void**) &rawPtr); - dpiOci__rawSize(props->env->handle, ociRaw, msgIdLength); - if (*msgIdLength > props->bufferLength) { - if (props->buffer) { - dpiUtils__freeMemory(props->buffer); - props->buffer = NULL; - } - if (dpiUtils__allocateMemory(1, *msgIdLength, 0, - "allocate msgid buffer", (void**) &props->buffer, error) < 0) - return DPI_FAILURE; - } - memcpy(props->buffer, rawPtr, *msgIdLength); - *msgId = props->buffer; - dpiOci__rawResize(props->env->handle, &ociRaw, 0, error); - return DPI_SUCCESS; + dpiOci__rawPtr(props->env->handle, props->msgIdRaw, (void**) msgId); + dpiOci__rawSize(props->env->handle, props->msgIdRaw, msgIdLength); } @@ -69,14 +64,22 @@ void dpiMsgProps__free(dpiMsgProps *props, dpiError *error) dpiOci__descriptorFree(props->handle, DPI_OCI_DTYPE_AQMSG_PROPERTIES); props->handle = NULL; } + if (props->payloadObj) { + dpiGen__setRefCount(props->payloadObj, error, -1); + props->payloadObj = NULL; + } + if (props->payloadRaw) { + dpiOci__rawResize(props->env->handle, &props->payloadRaw, 0, error); + props->payloadRaw = NULL; + } + if (props->msgIdRaw) { + dpiOci__rawResize(props->env->handle, &props->msgIdRaw, 0, error); + props->msgIdRaw = NULL; + } if (props->conn) { dpiGen__setRefCount(props->conn, error, -1); props->conn = NULL; } - if (props->buffer) { - dpiUtils__freeMemory(props->buffer); - props->buffer = NULL; - } dpiUtils__freeMemory(props); } @@ -91,8 +94,7 @@ static int dpiMsgProps__getAttrValue(dpiMsgProps *props, uint32_t attribute, dpiError error; int status; - if (dpiGen__startPublicFn(props, DPI_HTYPE_MSG_PROPS, fnName, 1, - &error) < 0) + if (dpiGen__startPublicFn(props, DPI_HTYPE_MSG_PROPS, fnName, &error) < 0) return dpiGen__endPublicFn(props, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(props, value) DPI_CHECK_PTR_NOT_NULL(props, valueLength) @@ -112,8 +114,7 @@ static int dpiMsgProps__setAttrValue(dpiMsgProps *props, uint32_t attribute, dpiError error; int status; - if (dpiGen__startPublicFn(props, DPI_HTYPE_MSG_PROPS, fnName, 1, - &error) < 0) + if (dpiGen__startPublicFn(props, DPI_HTYPE_MSG_PROPS, fnName, &error) < 0) return dpiGen__endPublicFn(props, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(props, value) status = dpiOci__attrSet(props->handle, DPI_OCI_DTYPE_AQMSG_PROPERTIES, @@ -181,7 +182,7 @@ int dpiMsgProps_getEnqTime(dpiMsgProps *props, dpiTimestamp *value) dpiOciDate ociValue; dpiError error; - if (dpiGen__startPublicFn(props, DPI_HTYPE_MSG_PROPS, __func__, 1, + if (dpiGen__startPublicFn(props, DPI_HTYPE_MSG_PROPS, __func__, &error) < 0) return dpiGen__endPublicFn(props, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(props, value) @@ -240,6 +241,32 @@ int dpiMsgProps_getNumAttempts(dpiMsgProps *props, int32_t *value) } +//----------------------------------------------------------------------------- +// dpiMsgProps_getMsgId() [PUBLIC] +// Return the message id for the message (available after enqueuing or +// dequeuing a message). +//----------------------------------------------------------------------------- +int dpiMsgProps_getMsgId(dpiMsgProps *props, const char **value, + uint32_t *valueLength) +{ + dpiError error; + + if (dpiGen__startPublicFn(props, DPI_HTYPE_MSG_PROPS, __func__, + &error) < 0) + return dpiGen__endPublicFn(props, DPI_FAILURE, &error); + DPI_CHECK_PTR_NOT_NULL(props, value) + DPI_CHECK_PTR_NOT_NULL(props, valueLength) + if (!props->msgIdRaw) { + *value = NULL; + *valueLength = 0; + } else { + dpiOci__rawPtr(props->env->handle, props->msgIdRaw, (void**) value); + dpiOci__rawSize(props->env->handle, props->msgIdRaw, valueLength); + } + return dpiGen__endPublicFn(props, DPI_SUCCESS, &error); +} + + //----------------------------------------------------------------------------- // dpiMsgProps_getOriginalMsgId() [PUBLIC] // Return the original message id for the message. @@ -250,7 +277,7 @@ int dpiMsgProps_getOriginalMsgId(dpiMsgProps *props, const char **value, dpiError error; void *rawValue; - if (dpiGen__startPublicFn(props, DPI_HTYPE_MSG_PROPS, __func__, 1, + if (dpiGen__startPublicFn(props, DPI_HTYPE_MSG_PROPS, __func__, &error) < 0) return dpiGen__endPublicFn(props, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(props, value) @@ -265,6 +292,36 @@ int dpiMsgProps_getOriginalMsgId(dpiMsgProps *props, const char **value, } +//----------------------------------------------------------------------------- +// dpiMsgProps_getPayload() [PUBLIC] +// Get the payload for the message (as an object or a series of bytes). +//----------------------------------------------------------------------------- +int dpiMsgProps_getPayload(dpiMsgProps *props, dpiObject **obj, + const char **value, uint32_t *valueLength) +{ + dpiError error; + + if (dpiGen__startPublicFn(props, DPI_HTYPE_MSG_PROPS, __func__, + &error) < 0) + return dpiGen__endPublicFn(props, DPI_FAILURE, &error); + if (obj) + *obj = props->payloadObj; + if (value && valueLength) { + if (props->payloadRaw) { + dpiOci__rawPtr(props->env->handle, props->payloadRaw, + (void**) value); + dpiOci__rawSize(props->env->handle, props->payloadRaw, + valueLength); + } else { + *value = NULL; + *valueLength = 0; + } + } + + return dpiGen__endPublicFn(props, DPI_SUCCESS, &error); +} + + //----------------------------------------------------------------------------- // dpiMsgProps_getPriority() [PUBLIC] // Return the priority of the message. @@ -359,7 +416,7 @@ int dpiMsgProps_setOriginalMsgId(dpiMsgProps *props, const char *value, dpiError error; int status; - if (dpiGen__startPublicFn(props, DPI_HTYPE_MSG_PROPS, __func__, 1, + if (dpiGen__startPublicFn(props, DPI_HTYPE_MSG_PROPS, __func__, &error) < 0) return dpiGen__endPublicFn(props, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(props, value) @@ -374,6 +431,51 @@ int dpiMsgProps_setOriginalMsgId(dpiMsgProps *props, const char *value, } +//----------------------------------------------------------------------------- +// dpiMsgProps_setPayloadBytes() [PUBLIC] +// Set the payload for the message (as a series of bytes). +//----------------------------------------------------------------------------- +int dpiMsgProps_setPayloadBytes(dpiMsgProps *props, const char *value, + uint32_t valueLength) +{ + dpiError error; + int status; + + if (dpiGen__startPublicFn(props, DPI_HTYPE_MSG_PROPS, __func__, + &error) < 0) + return dpiGen__endPublicFn(props, DPI_FAILURE, &error); + DPI_CHECK_PTR_NOT_NULL(props, value) + if (props->payloadRaw) { + dpiOci__rawResize(props->env->handle, &props->payloadRaw, 0, &error); + props->payloadRaw = NULL; + } + status = dpiOci__rawAssignBytes(props->env->handle, value, valueLength, + &props->payloadRaw, &error); + return dpiGen__endPublicFn(props, status, &error); +} + + +//----------------------------------------------------------------------------- +// dpiMsgProps_setPayloadObject() [PUBLIC] +// Set the payload for the message (as an object). +//----------------------------------------------------------------------------- +int dpiMsgProps_setPayloadObject(dpiMsgProps *props, dpiObject *obj) +{ + dpiError error; + + if (dpiGen__startPublicFn(props, DPI_HTYPE_MSG_PROPS, __func__, + &error) < 0) + return dpiGen__endPublicFn(props, DPI_FAILURE, &error); + if (dpiGen__checkHandle(obj, DPI_HTYPE_OBJECT, "check object", &error) < 0) + return dpiGen__endPublicFn(props, DPI_FAILURE, &error); + if (props->payloadObj) + dpiGen__setRefCount(props->payloadObj, &error, -1); + dpiGen__setRefCount(obj, &error, 1); + props->payloadObj = obj; + return dpiGen__endPublicFn(props, DPI_SUCCESS, &error); +} + + //----------------------------------------------------------------------------- // dpiMsgProps_setPriority() [PUBLIC] // Set the priority of the message. @@ -383,4 +485,3 @@ int dpiMsgProps_setPriority(dpiMsgProps *props, int32_t value) return dpiMsgProps__setAttrValue(props, DPI_OCI_ATTR_PRIORITY, __func__, &value, 0); } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiObject.c b/vendor/github.com/godror/godror/odpi/src/dpiObject.c similarity index 87% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiObject.c rename to vendor/github.com/godror/godror/odpi/src/dpiObject.c index 001789ddf5a..338c68aeeda 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiObject.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiObject.c @@ -16,6 +16,10 @@ #include "dpiImpl.h" +// forward declarations of internal functions only used in this file +int dpiObject__closeHelper(dpiObject *obj, int checkError, dpiError *error); + + //----------------------------------------------------------------------------- // dpiObject__allocate() [INTERNAL] // Allocate and initialize an object structure. @@ -66,7 +70,7 @@ int dpiObject__allocate(dpiObjectType *objType, void *instance, static int dpiObject__check(dpiObject *obj, const char *fnName, dpiError *error) { - if (dpiGen__startPublicFn(obj, DPI_HTYPE_OBJECT, fnName, 1, error) < 0) + if (dpiGen__startPublicFn(obj, DPI_HTYPE_OBJECT, fnName, error) < 0) return DPI_FAILURE; return dpiConn__checkConnected(obj->type->conn, error); } @@ -94,7 +98,8 @@ static int dpiObject__checkIsCollection(dpiObject *obj, const char *fnName, // Clear the Oracle value after use. //----------------------------------------------------------------------------- static void dpiObject__clearOracleValue(dpiObject *obj, dpiError *error, - dpiOracleDataBuffer *buffer, dpiOracleTypeNum oracleTypeNum) + dpiOracleDataBuffer *buffer, dpiLob *lob, + dpiOracleTypeNum oracleTypeNum) { switch (oracleTypeNum) { case DPI_ORACLE_TYPE_CHAR: @@ -129,12 +134,9 @@ static void dpiObject__clearOracleValue(dpiObject *obj, dpiError *error, case DPI_ORACLE_TYPE_NCLOB: case DPI_ORACLE_TYPE_BLOB: case DPI_ORACLE_TYPE_BFILE: - if (buffer->asLobLocator) { - dpiOci__lobFreeTemporary(obj->type->conn, buffer->asLobLocator, - 0, error); - dpiOci__descriptorFree(buffer->asLobLocator, - DPI_OCI_DTYPE_LOB); - } + if (lob) + dpiGen__setRefCount(lob, error, -1); + break; default: break; }; @@ -171,7 +173,7 @@ int dpiObject__close(dpiObject *obj, int checkError, dpiError *error) // flag; again, this must be done while holding the lock (if in threaded // mode) in order to avoid race conditions! if (obj->instance && !obj->dependsOnObj) { - if (dpiOci__objectFree(obj, checkError, error) < 0) { + if (dpiObject__closeHelper(obj, checkError, error) < 0) { if (obj->env->threaded) dpiMutex__acquire(obj->env->mutex); obj->closing = 0; @@ -179,17 +181,33 @@ int dpiObject__close(dpiObject *obj, int checkError, dpiError *error) dpiMutex__release(obj->env->mutex); return DPI_FAILURE; } - if (!obj->type->conn->closing) - dpiHandleList__removeHandle(obj->type->conn->objects, - obj->openSlotNum); - obj->instance = NULL; - obj->indicator = NULL; } return DPI_SUCCESS; } +//----------------------------------------------------------------------------- +// dpiObject__closeHelper() [INTERNAL] +// Helper function for closing an object. +//----------------------------------------------------------------------------- +int dpiObject__closeHelper(dpiObject *obj, int checkError, dpiError *error) +{ + if (dpiOci__objectFree(obj->env->handle, obj->instance, checkError, + error) < 0) + return DPI_FAILURE; + obj->instance = NULL; + if (obj->freeIndicator && dpiOci__objectFree(obj->env->handle, + obj->indicator, checkError, error) < 0) + return DPI_FAILURE; + obj->indicator = NULL; + if (!obj->type->conn->closing) + dpiHandleList__removeHandle(obj->type->conn->objects, + obj->openSlotNum); + return DPI_SUCCESS; +} + + //----------------------------------------------------------------------------- // dpiObject__free() [INTERNAL] // Free the memory for an object. @@ -260,9 +278,10 @@ static int dpiObject__fromOracleValue(dpiObject *obj, dpiError *error, } break; case DPI_ORACLE_TYPE_NATIVE_INT: - if (nativeTypeNum == DPI_NATIVE_TYPE_INT64) - return dpiDataBuffer__fromOracleNumberAsInteger(&data->value, - error, value->asNumber); + if (nativeTypeNum == DPI_NATIVE_TYPE_INT64) { + data->value.asInt64 = *value->asInt32; + return DPI_SUCCESS; + } break; case DPI_ORACLE_TYPE_NATIVE_FLOAT: if (nativeTypeNum == DPI_NATIVE_TYPE_FLOAT) { @@ -294,17 +313,26 @@ static int dpiObject__fromOracleValue(dpiObject *obj, dpiError *error, if (nativeTypeNum == DPI_NATIVE_TYPE_TIMESTAMP) return dpiDataBuffer__fromOracleDate(&data->value, value->asDate); + if (nativeTypeNum == DPI_NATIVE_TYPE_DOUBLE) + return dpiDataBuffer__fromOracleDateAsDouble(&data->value, + obj->env, error, value->asDate); break; case DPI_ORACLE_TYPE_TIMESTAMP: if (nativeTypeNum == DPI_NATIVE_TYPE_TIMESTAMP) return dpiDataBuffer__fromOracleTimestamp(&data->value, obj->env, error, *value->asTimestamp, 0); + if (nativeTypeNum == DPI_NATIVE_TYPE_DOUBLE) + return dpiDataBuffer__fromOracleTimestampAsDouble(&data->value, + obj->env, error, *value->asTimestamp); break; case DPI_ORACLE_TYPE_TIMESTAMP_TZ: case DPI_ORACLE_TYPE_TIMESTAMP_LTZ: if (nativeTypeNum == DPI_NATIVE_TYPE_TIMESTAMP) return dpiDataBuffer__fromOracleTimestamp(&data->value, obj->env, error, *value->asTimestamp, 1); + if (nativeTypeNum == DPI_NATIVE_TYPE_DOUBLE) + return dpiDataBuffer__fromOracleTimestampAsDouble(&data->value, + obj->env, error, *value->asTimestamp); break; case DPI_ORACLE_TYPE_OBJECT: if (typeInfo->objectType && @@ -366,8 +394,8 @@ static int dpiObject__fromOracleValue(dpiObject *obj, dpiError *error, //----------------------------------------------------------------------------- static int dpiObject__toOracleValue(dpiObject *obj, dpiError *error, const dpiDataTypeInfo *dataTypeInfo, dpiOracleDataBuffer *buffer, - void **ociValue, int16_t *valueIndicator, void **objectIndicator, - dpiNativeTypeNum nativeTypeNum, dpiData *data) + dpiLob **lob, void **ociValue, int16_t *valueIndicator, + void **objectIndicator, dpiNativeTypeNum nativeTypeNum, dpiData *data) { dpiOracleTypeNum valueOracleTypeNum; uint32_t handleType; @@ -413,6 +441,12 @@ static int dpiObject__toOracleValue(dpiObject *obj, dpiError *error, } break; case DPI_ORACLE_TYPE_NATIVE_INT: + if (nativeTypeNum == DPI_NATIVE_TYPE_INT64) { + buffer->asInt32 = (int32_t) data->value.asInt64; + *ociValue = &buffer->asInt32; + return DPI_SUCCESS; + } + break; case DPI_ORACLE_TYPE_NUMBER: *ociValue = &buffer->asNumber; if (nativeTypeNum == DPI_NATIVE_TYPE_INT64) @@ -448,25 +482,35 @@ static int dpiObject__toOracleValue(dpiObject *obj, dpiError *error, if (nativeTypeNum == DPI_NATIVE_TYPE_TIMESTAMP) return dpiDataBuffer__toOracleDate(&data->value, &buffer->asDate); + if (nativeTypeNum == DPI_NATIVE_TYPE_DOUBLE) + return dpiDataBuffer__toOracleDateFromDouble(&data->value, + obj->env, error, &buffer->asDate); break; case DPI_ORACLE_TYPE_TIMESTAMP: case DPI_ORACLE_TYPE_TIMESTAMP_TZ: case DPI_ORACLE_TYPE_TIMESTAMP_LTZ: buffer->asTimestamp = NULL; - if (nativeTypeNum == DPI_NATIVE_TYPE_TIMESTAMP) { - if (valueOracleTypeNum == DPI_ORACLE_TYPE_TIMESTAMP) + if (nativeTypeNum == DPI_NATIVE_TYPE_TIMESTAMP || + nativeTypeNum == DPI_NATIVE_TYPE_DOUBLE) { + if (valueOracleTypeNum == DPI_ORACLE_TYPE_TIMESTAMP_LTZ || + nativeTypeNum == DPI_NATIVE_TYPE_DOUBLE) { + handleType = DPI_OCI_DTYPE_TIMESTAMP_LTZ; + } else if (valueOracleTypeNum == DPI_ORACLE_TYPE_TIMESTAMP) { handleType = DPI_OCI_DTYPE_TIMESTAMP; - else if (valueOracleTypeNum == DPI_ORACLE_TYPE_TIMESTAMP_TZ) + } else { handleType = DPI_OCI_DTYPE_TIMESTAMP_TZ; - else handleType = DPI_OCI_DTYPE_TIMESTAMP_LTZ; + } if (dpiOci__descriptorAlloc(obj->env->handle, &buffer->asTimestamp, handleType, "allocate timestamp", error) < 0) return DPI_FAILURE; *ociValue = buffer->asTimestamp; - return dpiDataBuffer__toOracleTimestamp(&data->value, obj->env, - error, buffer->asTimestamp, - (valueOracleTypeNum != DPI_ORACLE_TYPE_TIMESTAMP)); + if (nativeTypeNum == DPI_NATIVE_TYPE_TIMESTAMP) + return dpiDataBuffer__toOracleTimestamp(&data->value, + obj->env, error, buffer->asTimestamp, + (valueOracleTypeNum != DPI_ORACLE_TYPE_TIMESTAMP)); + return dpiDataBuffer__toOracleTimestampFromDouble(&data->value, + obj->env, error, buffer->asTimestamp); } break; case DPI_ORACLE_TYPE_OBJECT: @@ -503,21 +547,15 @@ static int dpiObject__toOracleValue(dpiObject *obj, dpiError *error, return DPI_SUCCESS; } else if (nativeTypeNum == DPI_NATIVE_TYPE_BYTES) { const dpiOracleType *lobType; - dpiLob *tempLob; lobType = dpiOracleType__getFromNum(valueOracleTypeNum, error); - if (dpiLob__allocate(obj->type->conn, lobType, &tempLob, - error) < 0) + if (dpiLob__allocate(obj->type->conn, lobType, lob, error) < 0) return DPI_FAILURE; bytes = &data->value.asBytes; - if (dpiLob__setFromBytes(tempLob, bytes->ptr, bytes->length, - error) < 0) { - dpiLob__free(tempLob, error); + if (dpiLob__setFromBytes(*lob, bytes->ptr, bytes->length, + error) < 0) return DPI_FAILURE; - } - buffer->asLobLocator = tempLob->locator; - *ociValue = tempLob->locator; - tempLob->locator = NULL; - dpiLob__free(tempLob, error); + buffer->asLobLocator = (*lob)->locator; + *ociValue = (*lob)->locator; return DPI_SUCCESS; } break; @@ -550,6 +588,7 @@ int dpiObject_appendElement(dpiObject *obj, dpiNativeTypeNum nativeTypeNum, { dpiOracleDataBuffer valueBuffer; int16_t scalarValueIndicator; + dpiLob *lob = NULL; void *indicator; dpiError error; void *ociValue; @@ -558,15 +597,16 @@ int dpiObject_appendElement(dpiObject *obj, dpiNativeTypeNum nativeTypeNum, if (dpiObject__checkIsCollection(obj, __func__, &error) < 0) return dpiGen__endPublicFn(obj, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(obj, data) - if (dpiObject__toOracleValue(obj, &error, &obj->type->elementTypeInfo, - &valueBuffer, &ociValue, &scalarValueIndicator, - (void**) &indicator, nativeTypeNum, data) < 0) - return dpiGen__endPublicFn(obj, DPI_FAILURE, &error); - if (!indicator) - indicator = &scalarValueIndicator; - status = dpiOci__collAppend(obj->type->conn, ociValue, indicator, - obj->instance, &error); - dpiObject__clearOracleValue(obj, &error, &valueBuffer, + status = dpiObject__toOracleValue(obj, &error, &obj->type->elementTypeInfo, + &valueBuffer, &lob, &ociValue, &scalarValueIndicator, + (void**) &indicator, nativeTypeNum, data); + if (status == DPI_SUCCESS) { + if (!indicator) + indicator = &scalarValueIndicator; + status = dpiOci__collAppend(obj->type->conn, ociValue, indicator, + obj->instance, &error); + } + dpiObject__clearOracleValue(obj, &error, &valueBuffer, lob, obj->type->elementTypeInfo.oracleTypeNum); return dpiGen__endPublicFn(obj, status, &error); } @@ -836,6 +876,7 @@ int dpiObject_setAttributeValue(dpiObject *obj, dpiObjectAttr *attr, void *valueIndicator, *ociValue; dpiOracleDataBuffer valueBuffer; int16_t scalarValueIndicator; + dpiLob *lob = NULL; dpiError error; int status; @@ -861,15 +902,15 @@ int dpiObject_setAttributeValue(dpiObject *obj, dpiObjectAttr *attr, } // convert to input data format - if (dpiObject__toOracleValue(obj, &error, &attr->typeInfo, &valueBuffer, - &ociValue, &scalarValueIndicator, &valueIndicator, nativeTypeNum, - data) < 0) - return dpiGen__endPublicFn(obj, DPI_FAILURE, &error); + status = dpiObject__toOracleValue(obj, &error, &attr->typeInfo, + &valueBuffer, &lob, &ociValue, &scalarValueIndicator, + &valueIndicator, nativeTypeNum, data); // set attribute value - status = dpiOci__objectSetAttr(obj, attr, scalarValueIndicator, - valueIndicator, ociValue, &error); - dpiObject__clearOracleValue(obj, &error, &valueBuffer, + if (status == DPI_SUCCESS) + status = dpiOci__objectSetAttr(obj, attr, scalarValueIndicator, + valueIndicator, ociValue, &error); + dpiObject__clearOracleValue(obj, &error, &valueBuffer, lob, attr->typeInfo.oracleTypeNum); return dpiGen__endPublicFn(obj, status, &error); } @@ -884,6 +925,7 @@ int dpiObject_setElementValueByIndex(dpiObject *obj, int32_t index, { dpiOracleDataBuffer valueBuffer; int16_t scalarValueIndicator; + dpiLob *lob = NULL; void *indicator; dpiError error; void *ociValue; @@ -892,15 +934,16 @@ int dpiObject_setElementValueByIndex(dpiObject *obj, int32_t index, if (dpiObject__checkIsCollection(obj, __func__, &error) < 0) return dpiGen__endPublicFn(obj, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(obj, data) - if (dpiObject__toOracleValue(obj, &error, &obj->type->elementTypeInfo, - &valueBuffer, &ociValue, &scalarValueIndicator, - (void**) &indicator, nativeTypeNum, data) < 0) - return dpiGen__endPublicFn(obj, DPI_FAILURE, &error); - if (!indicator) - indicator = &scalarValueIndicator; - status = dpiOci__collAssignElem(obj->type->conn, index, ociValue, - indicator, obj->instance, &error); - dpiObject__clearOracleValue(obj, &error, &valueBuffer, + status = dpiObject__toOracleValue(obj, &error, &obj->type->elementTypeInfo, + &valueBuffer, &lob, &ociValue, &scalarValueIndicator, + (void**) &indicator, nativeTypeNum, data); + if (status == DPI_SUCCESS) { + if (!indicator) + indicator = &scalarValueIndicator; + status = dpiOci__collAssignElem(obj->type->conn, index, ociValue, + indicator, obj->instance, &error); + } + dpiObject__clearOracleValue(obj, &error, &valueBuffer, lob, obj->type->elementTypeInfo.oracleTypeNum); return dpiGen__endPublicFn(obj, status, &error); } @@ -921,4 +964,3 @@ int dpiObject_trim(dpiObject *obj, uint32_t numToTrim) &error); return dpiGen__endPublicFn(obj, status, &error); } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiObjectAttr.c b/vendor/github.com/godror/godror/odpi/src/dpiObjectAttr.c similarity index 99% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiObjectAttr.c rename to vendor/github.com/godror/godror/odpi/src/dpiObjectAttr.c index 573abc68217..45d623ef573 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiObjectAttr.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiObjectAttr.c @@ -93,7 +93,7 @@ int dpiObjectAttr_getInfo(dpiObjectAttr *attr, dpiObjectAttrInfo *info) { dpiError error; - if (dpiGen__startPublicFn(attr, DPI_HTYPE_OBJECT_ATTR, __func__, 0, + if (dpiGen__startPublicFn(attr, DPI_HTYPE_OBJECT_ATTR, __func__, &error) < 0) return dpiGen__endPublicFn(attr, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(attr, info) @@ -112,4 +112,3 @@ int dpiObjectAttr_release(dpiObjectAttr *attr) { return dpiGen__release(attr, DPI_HTYPE_OBJECT_ATTR, __func__); } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiObjectType.c b/vendor/github.com/godror/godror/odpi/src/dpiObjectType.c similarity index 99% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiObjectType.c rename to vendor/github.com/godror/godror/odpi/src/dpiObjectType.c index 9030b397839..fbb2cf240c8 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiObjectType.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiObjectType.c @@ -57,7 +57,7 @@ int dpiObjectType__allocate(dpiConn *conn, void *param, static int dpiObjectType__check(dpiObjectType *objType, const char *fnName, dpiError *error) { - if (dpiGen__startPublicFn(objType, DPI_HTYPE_OBJECT_TYPE, fnName, 1, + if (dpiGen__startPublicFn(objType, DPI_HTYPE_OBJECT_TYPE, fnName, error) < 0) return DPI_FAILURE; return dpiConn__checkConnected(objType->conn, error); @@ -319,7 +319,7 @@ int dpiObjectType_getInfo(dpiObjectType *objType, dpiObjectTypeInfo *info) { dpiError error; - if (dpiGen__startPublicFn(objType, DPI_HTYPE_OBJECT_TYPE, __func__, 0, + if (dpiGen__startPublicFn(objType, DPI_HTYPE_OBJECT_TYPE, __func__, &error) < 0) return dpiGen__endPublicFn(objType, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(objType, info) @@ -342,4 +342,3 @@ int dpiObjectType_release(dpiObjectType *objType) { return dpiGen__release(objType, DPI_HTYPE_OBJECT_TYPE, __func__); } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiOci.c b/vendor/github.com/godror/godror/odpi/src/dpiOci.c similarity index 85% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiOci.c rename to vendor/github.com/godror/godror/odpi/src/dpiOci.c index 2ad76c688d5..c731324cb48 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiOci.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiOci.c @@ -35,14 +35,35 @@ static void *dpiOci__reallocMem(void *unused, void *ptr, size_t newSize); error) < 0) \ return DPI_FAILURE; +// macro to ensure that an error handle is available +#define DPI_OCI_ENSURE_ERROR_HANDLE(error) \ + if (!error->handle && dpiError__initHandle(error) < 0) \ + return DPI_FAILURE; + +// macros to simplify code for checking results of OCI calls +#define DPI_OCI_ERROR_OCCURRED(status) \ + (status != DPI_OCI_SUCCESS && status != DPI_OCI_SUCCESS_WITH_INFO) +#define DPI_OCI_CHECK_AND_RETURN(error, status, conn, action) \ + if (DPI_OCI_ERROR_OCCURRED(status)) \ + return dpiError__setFromOCI(error, status, conn, action); \ + return DPI_SUCCESS; + // typedefs for all OCI functions used by ODPI-C typedef int (*dpiOciFnType__aqDeq)(void *svchp, void *errhp, const char *queue_name, void *deqopt, void *msgprop, void *payload_tdo, void **payload, void **payload_ind, void **msgid, uint32_t flags); +typedef int (*dpiOciFnType__aqDeqArray)(void *svchp, void *errhp, + const char *queue_name, void *deqopt, uint32_t *iters, void **msgprop, + void *payload_tdo, void **payload, void **payload_ind, void **msgid, + void *ctxp, void *deqcbfp, uint32_t flags); typedef int (*dpiOciFnType__aqEnq)(void *svchp, void *errhp, const char *queue_name, void *enqopt, void *msgprop, void *payload_tdo, void **payload, void **payload_ind, void **msgid, uint32_t flags); +typedef int (*dpiOciFnType__aqEnqArray)(void *svchp, void *errhp, + const char *queue_name, void *enqopt, uint32_t *iters, void **msgprop, + void *payload_tdo, void **payload, void **payload_ind, void **msgid, + void *ctxp, void *enqcbfp, uint32_t flags); typedef int (*dpiOciFnType__arrayDescriptorAlloc)(const void *parenth, void **descpp, const uint32_t type, uint32_t array_size, const size_t xtramem_sz, void **usrmempp); @@ -99,6 +120,8 @@ typedef int (*dpiOciFnType__dateTimeConstruct)(void *hndl, void *err, void *datetime, int16_t yr, uint8_t mnth, uint8_t dy, uint8_t hr, uint8_t mm, uint8_t ss, uint32_t fsec, const char *tz, size_t tzLength); +typedef int (*dpiOciFnType__dateTimeConvert)(void *hndl, void *err, + void *indate, void *outdate); typedef int (*dpiOciFnType__dateTimeGetDate)(void *hndl, void *err, const void *date, int16_t *yr, uint8_t *mnth, uint8_t *dy); typedef int (*dpiOciFnType__dateTimeGetTime)(void *hndl, void *err, @@ -283,6 +306,12 @@ typedef int (*dpiOciFnType__sessionRelease)(void *svchp, void *errhp, typedef int (*dpiOciFnType__shardingKeyColumnAdd)(void *shardingKey, void *errhp, void *col, uint32_t colLen, uint16_t colType, uint32_t mode); +typedef int (*dpiOciFnType__sodaBulkInsert)(void *svchp, + void *collection, void **documentarray, uint32_t arraylen, + void *opoptns, void *errhp, uint32_t mode); +typedef int (*dpiOciFnType__sodaBulkInsertAndGet)(void *svchp, + void *collection, void **documentarray, uint32_t arraylen, + void *opoptns, void *errhp, uint32_t mode); typedef int (*dpiOciFnType__sodaCollCreateWithMetadata)(void *svchp, const char *collname, uint32_t collnamelen, const char *metadata, uint32_t metadatalen, void **collection, void *errhp, uint32_t mode); @@ -389,6 +418,10 @@ typedef int (*dpiOciFnType__typeByFullName)(void *env, void *err, uint32_t full_type_name_length, const char *version_name, uint32_t version_name_length, uint16_t pin_duration, int get_option, void **tdo); +typedef int (*dpiOciFnType__typeByName)(void *env, void *err, const void *svc, + const char *schema_name, uint32_t s_length, const char *type_name, + uint32_t t_length, const char *version_name, uint32_t v_length, + uint16_t pin_duration, int get_option, void **tdo); // library handle for dynamically loaded OCI library @@ -400,16 +433,18 @@ static const char *dpiOciLibNames[] = { "oci.dll", #elif __APPLE__ "libclntsh.dylib", + "libclntsh.dylib.19.1", "libclntsh.dylib.18.1", "libclntsh.dylib.12.1", "libclntsh.dylib.11.1", - "libclntsh.dylib.19.1", + "libclntsh.dylib.20.1", #else "libclntsh.so", + "libclntsh.so.19.1", "libclntsh.so.18.1", "libclntsh.so.12.1", "libclntsh.so.11.1", - "libclntsh.so.19.1", + "libclntsh.so.20.1", #endif NULL }; @@ -429,7 +464,9 @@ static dpiVersionInfo dpiOciLibVersionInfo; // all OCI symbols used by ODPI-C static struct { dpiOciFnType__aqDeq fnAqDeq; + dpiOciFnType__aqDeqArray fnAqDeqArray; dpiOciFnType__aqEnq fnAqEnq; + dpiOciFnType__aqEnqArray fnAqEnqArray; dpiOciFnType__arrayDescriptorAlloc fnArrayDescriptorAlloc; dpiOciFnType__arrayDescriptorFree fnArrayDescriptorFree; dpiOciFnType__attrGet fnAttrGet; @@ -450,6 +487,7 @@ static struct { dpiOciFnType__contextGetValue fnContextGetValue; dpiOciFnType__contextSetValue fnContextSetValue; dpiOciFnType__dateTimeConstruct fnDateTimeConstruct; + dpiOciFnType__dateTimeConvert fnDateTimeConvert; dpiOciFnType__dateTimeGetDate fnDateTimeGetDate; dpiOciFnType__dateTimeGetTime fnDateTimeGetTime; dpiOciFnType__dateTimeGetTimeZoneOffset fnDateTimeGetTimeZoneOffset; @@ -526,6 +564,8 @@ static struct { dpiOciFnType__sessionRelease fnSessionRelease; dpiOciFnType__shardingKeyColumnAdd fnShardingKeyColumnAdd; dpiOciFnType__stmtExecute fnStmtExecute; + dpiOciFnType__sodaBulkInsert fnSodaBulkInsert; + dpiOciFnType__sodaBulkInsertAndGet fnSodaBulkInsertAndGet; dpiOciFnType__sodaCollCreateWithMetadata fnSodaCollCreateWithMetadata; dpiOciFnType__sodaCollDrop fnSodaCollDrop; dpiOciFnType__sodaCollGetNext fnSodaCollGetNext; @@ -572,6 +612,7 @@ static struct { dpiOciFnType__transRollback fnTransRollback; dpiOciFnType__transStart fnTransStart; dpiOciFnType__typeByFullName fnTypeByFullName; + dpiOciFnType__typeByName fnTypeByName; } dpiOciSymbols; @@ -580,7 +621,7 @@ static struct { // Wrapper for OCI allocation of memory, only used when debugging memory // allocation. //----------------------------------------------------------------------------- -static void *dpiOci__allocateMem(void *unused, size_t size) +static void *dpiOci__allocateMem(UNUSED void *unused, size_t size) { void *ptr; @@ -601,10 +642,30 @@ int dpiOci__aqDeq(dpiConn *conn, const char *queueName, void *options, int status; DPI_OCI_LOAD_SYMBOL("OCIAQDeq", dpiOciSymbols.fnAqDeq) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnAqDeq)(conn->handle, error->handle, queueName, options, msgProps, payloadType, payload, payloadInd, msgId, DPI_OCI_DEFAULT); - return dpiError__check(error, status, conn, "dequeue message"); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "dequeue message"); +} + + +//----------------------------------------------------------------------------- +// dpiOci__aqDeqArray() [INTERNAL] +// Wrapper for OCIAQDeqArray(). +//----------------------------------------------------------------------------- +int dpiOci__aqDeqArray(dpiConn *conn, const char *queueName, void *options, + uint32_t *numIters, void **msgProps, void *payloadType, void **payload, + void **payloadInd, void **msgId, dpiError *error) +{ + int status; + + DPI_OCI_LOAD_SYMBOL("OCIAQDeqArray", dpiOciSymbols.fnAqDeqArray) + DPI_OCI_ENSURE_ERROR_HANDLE(error) + status = (*dpiOciSymbols.fnAqDeqArray)(conn->handle, error->handle, + queueName, options, numIters, msgProps, payloadType, payload, + payloadInd, msgId, NULL, NULL, DPI_OCI_DEFAULT); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "dequeue messages"); } @@ -619,10 +680,30 @@ int dpiOci__aqEnq(dpiConn *conn, const char *queueName, void *options, int status; DPI_OCI_LOAD_SYMBOL("OCIAQEnq", dpiOciSymbols.fnAqEnq) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnAqEnq)(conn->handle, error->handle, queueName, options, msgProps, payloadType, payload, payloadInd, msgId, DPI_OCI_DEFAULT); - return dpiError__check(error, status, conn, "enqueue message"); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "enqueue message"); +} + + +//----------------------------------------------------------------------------- +// dpiOci__aqEnqArray() [INTERNAL] +// Wrapper for OCIAQEnqArray(). +//----------------------------------------------------------------------------- +int dpiOci__aqEnqArray(dpiConn *conn, const char *queueName, void *options, + uint32_t *numIters, void **msgProps, void *payloadType, void **payload, + void **payloadInd, void **msgId, dpiError *error) +{ + int status; + + DPI_OCI_LOAD_SYMBOL("OCIAQEnqArray", dpiOciSymbols.fnAqEnqArray) + DPI_OCI_ENSURE_ERROR_HANDLE(error) + status = (*dpiOciSymbols.fnAqEnqArray)(conn->handle, error->handle, + queueName, options, numIters, msgProps, payloadType, payload, + payloadInd, msgId, NULL, NULL, DPI_OCI_DEFAULT); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "enqueue messages"); } @@ -639,7 +720,7 @@ int dpiOci__arrayDescriptorAlloc(void *envHandle, void **handle, dpiOciSymbols.fnArrayDescriptorAlloc) status = (*dpiOciSymbols.fnArrayDescriptorAlloc)(envHandle, handle, handleType, arraySize, 0, NULL); - return dpiError__check(error, status, NULL, "allocate descriptors"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "allocate descriptors"); } @@ -672,11 +753,12 @@ int dpiOci__attrGet(const void *handle, uint32_t handleType, void *ptr, { int status; + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnAttrGet)(handle, handleType, ptr, size, attribute, error->handle); - if (action) - return dpiError__check(error, status, NULL, action); - return DPI_SUCCESS; + if (!action) + return DPI_SUCCESS; + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, action); } @@ -689,11 +771,12 @@ int dpiOci__attrSet(void *handle, uint32_t handleType, void *ptr, { int status; + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnAttrSet)(handle, handleType, ptr, size, attribute, error->handle); - if (action) - return dpiError__check(error, status, NULL, action); - return DPI_SUCCESS; + if (!action) + return DPI_SUCCESS; + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, action); } @@ -707,6 +790,7 @@ int dpiOci__bindByName(dpiStmt *stmt, void **bindHandle, const char *name, int status; DPI_OCI_LOAD_SYMBOL("OCIBindByName", dpiOciSymbols.fnBindByName) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnBindByName)(stmt->handle, bindHandle, error->handle, name, nameLength, (dynamicBind) ? NULL : var->buffer.data.asRaw, @@ -719,7 +803,7 @@ int dpiOci__bindByName(dpiStmt *stmt, void **bindHandle, const char *name, (var->isArray) ? var->buffer.maxArraySize : 0, (var->isArray) ? &var->buffer.actualArraySize : NULL, (dynamicBind) ? DPI_OCI_DATA_AT_EXEC : DPI_OCI_DEFAULT); - return dpiError__check(error, status, stmt->conn, "bind by name"); + DPI_OCI_CHECK_AND_RETURN(error, status, stmt->conn, "bind by name"); } @@ -733,6 +817,7 @@ int dpiOci__bindByName2(dpiStmt *stmt, void **bindHandle, const char *name, int status; DPI_OCI_LOAD_SYMBOL("OCIBindByName2", dpiOciSymbols.fnBindByName2) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnBindByName2)(stmt->handle, bindHandle, error->handle, name, nameLength, (dynamicBind) ? NULL : var->buffer.data.asRaw, @@ -745,7 +830,7 @@ int dpiOci__bindByName2(dpiStmt *stmt, void **bindHandle, const char *name, (var->isArray) ? var->buffer.maxArraySize : 0, (var->isArray) ? &var->buffer.actualArraySize : NULL, (dynamicBind) ? DPI_OCI_DATA_AT_EXEC : DPI_OCI_DEFAULT); - return dpiError__check(error, status, stmt->conn, "bind by name"); + DPI_OCI_CHECK_AND_RETURN(error, status, stmt->conn, "bind by name"); } @@ -759,6 +844,7 @@ int dpiOci__bindByPos(dpiStmt *stmt, void **bindHandle, uint32_t pos, int status; DPI_OCI_LOAD_SYMBOL("OCIBindByPos", dpiOciSymbols.fnBindByPos) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnBindByPos)(stmt->handle, bindHandle, error->handle, pos, (dynamicBind) ? NULL : var->buffer.data.asRaw, (var->isDynamic) ? INT_MAX : (int32_t) var->sizeInBytes, @@ -770,7 +856,7 @@ int dpiOci__bindByPos(dpiStmt *stmt, void **bindHandle, uint32_t pos, (var->isArray) ? var->buffer.maxArraySize : 0, (var->isArray) ? &var->buffer.actualArraySize : NULL, (dynamicBind) ? DPI_OCI_DATA_AT_EXEC : DPI_OCI_DEFAULT); - return dpiError__check(error, status, stmt->conn, "bind by position"); + DPI_OCI_CHECK_AND_RETURN(error, status, stmt->conn, "bind by position"); } @@ -784,6 +870,7 @@ int dpiOci__bindByPos2(dpiStmt *stmt, void **bindHandle, uint32_t pos, int status; DPI_OCI_LOAD_SYMBOL("OCIBindByPos2", dpiOciSymbols.fnBindByPos2) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnBindByPos2)(stmt->handle, bindHandle, error->handle, pos, (dynamicBind) ? NULL : var->buffer.data.asRaw, (var->isDynamic) ? INT_MAX : var->sizeInBytes, @@ -795,7 +882,7 @@ int dpiOci__bindByPos2(dpiStmt *stmt, void **bindHandle, uint32_t pos, (var->isArray) ? var->buffer.maxArraySize : 0, (var->isArray) ? &var->buffer.actualArraySize : NULL, (dynamicBind) ? DPI_OCI_DATA_AT_EXEC : DPI_OCI_DEFAULT); - return dpiError__check(error, status, stmt->conn, "bind by position"); + DPI_OCI_CHECK_AND_RETURN(error, status, stmt->conn, "bind by position"); } @@ -808,10 +895,11 @@ int dpiOci__bindDynamic(dpiVar *var, void *bindHandle, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCIBindDynamic", dpiOciSymbols.fnBindDynamic) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnBindDynamic)(bindHandle, error->handle, var, (void*) dpiVar__inBindCallback, var, (void*) dpiVar__outBindCallback); - return dpiError__check(error, status, var->conn, "bind dynamic"); + DPI_OCI_CHECK_AND_RETURN(error, status, var->conn, "bind dynamic"); } @@ -824,10 +912,11 @@ int dpiOci__bindObject(dpiVar *var, void *bindHandle, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCIBindObject", dpiOciSymbols.fnBindObject) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnBindObject)(bindHandle, error->handle, var->objectType->tdo, (void**) var->buffer.data.asRaw, 0, var->buffer.objectIndicator, 0); - return dpiError__check(error, status, var->conn, "bind object"); + DPI_OCI_CHECK_AND_RETURN(error, status, var->conn, "bind object"); } @@ -840,8 +929,9 @@ int dpiOci__break(dpiConn *conn, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCIBreak", dpiOciSymbols.fnBreak) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnBreak)(conn->handle, error->handle); - return dpiError__check(error, status, conn, "break execution"); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "break execution"); } @@ -866,9 +956,10 @@ int dpiOci__collAppend(dpiConn *conn, const void *elem, const void *elemInd, int status; DPI_OCI_LOAD_SYMBOL("OCICollAppend", dpiOciSymbols.fnCollAppend) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnCollAppend)(conn->env->handle, error->handle, elem, elemInd, coll); - return dpiError__check(error, status, conn, "append element"); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "append element"); } @@ -882,9 +973,10 @@ int dpiOci__collAssignElem(dpiConn *conn, int32_t index, const void *elem, int status; DPI_OCI_LOAD_SYMBOL("OCICollAssignElem", dpiOciSymbols.fnCollAssignElem) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnCollAssignElem)(conn->env->handle, error->handle, index, elem, elemInd, coll); - return dpiError__check(error, status, conn, "assign element"); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "assign element"); } @@ -898,9 +990,10 @@ int dpiOci__collGetElem(dpiConn *conn, void *coll, int32_t index, int *exists, int status; DPI_OCI_LOAD_SYMBOL("OCICollGetElem", dpiOciSymbols.fnCollGetElem) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnCollGetElem)(conn->env->handle, error->handle, coll, index, exists, elem, elemInd); - return dpiError__check(error, status, conn, "get element"); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "get element"); } @@ -913,9 +1006,10 @@ int dpiOci__collSize(dpiConn *conn, void *coll, int32_t *size, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCICollSize", dpiOciSymbols.fnCollSize) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnCollSize)(conn->env->handle, error->handle, coll, size); - return dpiError__check(error, status, conn, "get size"); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "get size"); } @@ -929,9 +1023,10 @@ int dpiOci__collTrim(dpiConn *conn, uint32_t numToTrim, void *coll, int status; DPI_OCI_LOAD_SYMBOL("OCICollTrim", dpiOciSymbols.fnCollTrim) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnCollTrim)(conn->env->handle, error->handle, (int32_t) numToTrim, coll); - return dpiError__check(error, status, conn, "trim"); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "trim"); } @@ -945,11 +1040,12 @@ int dpiOci__contextGetValue(dpiConn *conn, const char *key, uint32_t keyLength, int status; DPI_OCI_LOAD_SYMBOL("OCIContextGetValue", dpiOciSymbols.fnContextGetValue) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnContextGetValue)(conn->sessionHandle, error->handle, key, (uint8_t) keyLength, value); - if (checkError) - return dpiError__check(error, status, conn, "get context value"); - return DPI_SUCCESS; + if (!checkError) + return DPI_SUCCESS; + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "get context value"); } @@ -963,12 +1059,13 @@ int dpiOci__contextSetValue(dpiConn *conn, const char *key, uint32_t keyLength, int status; DPI_OCI_LOAD_SYMBOL("OCIContextSetValue", dpiOciSymbols.fnContextSetValue) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnContextSetValue)(conn->sessionHandle, error->handle, DPI_OCI_DURATION_SESSION, key, (uint8_t) keyLength, value); - if (checkError) - return dpiError__check(error, status, conn, "set context value"); - return DPI_SUCCESS; + if (!checkError) + return DPI_SUCCESS; + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "set context value"); } @@ -985,10 +1082,28 @@ int dpiOci__dateTimeConstruct(void *envHandle, void *handle, int16_t year, DPI_OCI_LOAD_SYMBOL("OCIDateTimeConstruct", dpiOciSymbols.fnDateTimeConstruct) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnDateTimeConstruct)(envHandle, error->handle, handle, year, month, day, hour, minute, second, fsecond, tz, tzLength); - return dpiError__check(error, status, NULL, "construct date"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "construct date"); +} + + +//----------------------------------------------------------------------------- +// dpiOci__dateTimeConvert() [INTERNAL] +// Wrapper for OCIDateTimeConvert(). +//----------------------------------------------------------------------------- +int dpiOci__dateTimeConvert(void *envHandle, void *inDate, void *outDate, + dpiError *error) +{ + int status; + + DPI_OCI_LOAD_SYMBOL("OCIDateTimeConvert", dpiOciSymbols.fnDateTimeConvert) + DPI_OCI_ENSURE_ERROR_HANDLE(error) + status = (*dpiOciSymbols.fnDateTimeConvert)(envHandle, error->handle, + inDate, outDate); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "convert date"); } @@ -1002,9 +1117,10 @@ int dpiOci__dateTimeGetDate(void *envHandle, void *handle, int16_t *year, int status; DPI_OCI_LOAD_SYMBOL("OCIDateTimeGetDate", dpiOciSymbols.fnDateTimeGetDate) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnDateTimeGetDate)(envHandle, error->handle, handle, year, month, day); - return dpiError__check(error, status, NULL, "get date portion"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "get date portion"); } @@ -1018,9 +1134,10 @@ int dpiOci__dateTimeGetTime(void *envHandle, void *handle, uint8_t *hour, int status; DPI_OCI_LOAD_SYMBOL("OCIDateTimeGetTime", dpiOciSymbols.fnDateTimeGetTime) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnDateTimeGetTime)(envHandle, error->handle, handle, hour, minute, second, fsecond); - return dpiError__check(error, status, NULL, "get time portion"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "get time portion"); } @@ -1035,9 +1152,10 @@ int dpiOci__dateTimeGetTimeZoneOffset(void *envHandle, void *handle, DPI_OCI_LOAD_SYMBOL("OCIDateTimeGetTimeZoneOffset", dpiOciSymbols.fnDateTimeGetTimeZoneOffset) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnDateTimeGetTimeZoneOffset)(envHandle, error->handle, handle, tzHourOffset, tzMinuteOffset); - return dpiError__check(error, status, NULL, "get time zone portion"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "get time zone portion"); } @@ -1052,9 +1170,10 @@ int dpiOci__dateTimeIntervalAdd(void *envHandle, void *handle, void *interval, DPI_OCI_LOAD_SYMBOL("OCIDateTimeIntervalAdd", dpiOciSymbols.fnDateTimeIntervalAdd) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnDateTimeIntervalAdd)(envHandle, error->handle, handle, interval, outHandle); - return dpiError__check(error, status, NULL, "add interval to date"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "add interval to date"); } @@ -1069,9 +1188,10 @@ int dpiOci__dateTimeSubtract(void *envHandle, void *handle1, void *handle2, DPI_OCI_LOAD_SYMBOL("OCIDateTimeSubtract", dpiOciSymbols.fnDateTimeSubtract) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnDateTimeSubtract)(envHandle, error->handle, handle1, handle2, interval); - return dpiError__check(error, status, NULL, "subtract date"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "subtract date"); } @@ -1084,9 +1204,10 @@ int dpiOci__dbShutdown(dpiConn *conn, uint32_t mode, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCIDBShutdown", dpiOciSymbols.fnDbShutdown) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnDbShutdown)(conn->handle, error->handle, NULL, mode); - return dpiError__check(error, status, NULL, "shutdown database"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "shutdown database"); } @@ -1099,9 +1220,10 @@ int dpiOci__dbStartup(dpiConn *conn, uint32_t mode, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCIDBStartup", dpiOciSymbols.fnDbStartup) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnDbStartup)(conn->handle, error->handle, NULL, DPI_OCI_DEFAULT, mode); - return dpiError__check(error, status, NULL, "startup database"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "startup database"); } @@ -1115,6 +1237,7 @@ int dpiOci__defineByPos(dpiStmt *stmt, void **defineHandle, uint32_t pos, int status; DPI_OCI_LOAD_SYMBOL("OCIDefineByPos", dpiOciSymbols.fnDefineByPos) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnDefineByPos)(stmt->handle, defineHandle, error->handle, pos, (var->isDynamic) ? NULL : var->buffer.data.asRaw, @@ -1124,7 +1247,7 @@ int dpiOci__defineByPos(dpiStmt *stmt, void **defineHandle, uint32_t pos, (var->isDynamic) ? NULL : var->buffer.actualLength16, (var->isDynamic) ? NULL : var->buffer.returnCode, (var->isDynamic) ? DPI_OCI_DYNAMIC_FETCH : DPI_OCI_DEFAULT); - return dpiError__check(error, status, stmt->conn, "define"); + DPI_OCI_CHECK_AND_RETURN(error, status, stmt->conn, "define"); } @@ -1138,6 +1261,7 @@ int dpiOci__defineByPos2(dpiStmt *stmt, void **defineHandle, uint32_t pos, int status; DPI_OCI_LOAD_SYMBOL("OCIDefineByPos2", dpiOciSymbols.fnDefineByPos2) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnDefineByPos2)(stmt->handle, defineHandle, error->handle, pos, (var->isDynamic) ? NULL : var->buffer.data.asRaw, @@ -1147,7 +1271,7 @@ int dpiOci__defineByPos2(dpiStmt *stmt, void **defineHandle, uint32_t pos, (var->isDynamic) ? NULL : var->buffer.actualLength32, (var->isDynamic) ? NULL : var->buffer.returnCode, (var->isDynamic) ? DPI_OCI_DYNAMIC_FETCH : DPI_OCI_DEFAULT); - return dpiError__check(error, status, stmt->conn, "define"); + DPI_OCI_CHECK_AND_RETURN(error, status, stmt->conn, "define"); } @@ -1160,9 +1284,10 @@ int dpiOci__defineDynamic(dpiVar *var, void *defineHandle, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCIDefineDynamic", dpiOciSymbols.fnDefineDynamic) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnDefineDynamic)(defineHandle, error->handle, var, (void*) dpiVar__defineCallback); - return dpiError__check(error, status, var->conn, "define dynamic"); + DPI_OCI_CHECK_AND_RETURN(error, status, var->conn, "define dynamic"); } @@ -1175,10 +1300,11 @@ int dpiOci__defineObject(dpiVar *var, void *defineHandle, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCIDefineObject", dpiOciSymbols.fnDefineObject) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnDefineObject)(defineHandle, error->handle, var->objectType->tdo, (void**) var->buffer.data.asRaw, 0, var->buffer.objectIndicator, 0); - return dpiError__check(error, status, var->conn, "define object"); + DPI_OCI_CHECK_AND_RETURN(error, status, var->conn, "define object"); } @@ -1192,9 +1318,10 @@ int dpiOci__describeAny(dpiConn *conn, void *obj, uint32_t objLength, int status; DPI_OCI_LOAD_SYMBOL("OCIDescribeAny", dpiOciSymbols.fnDescribeAny) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnDescribeAny)(conn->handle, error->handle, obj, objLength, objType, 0, DPI_OCI_PTYPE_TYPE, describeHandle); - return dpiError__check(error, status, conn, "describe type"); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "describe type"); } @@ -1210,7 +1337,7 @@ int dpiOci__descriptorAlloc(void *envHandle, void **handle, DPI_OCI_LOAD_SYMBOL("OCIDescriptorAlloc", dpiOciSymbols.fnDescriptorAlloc) status = (*dpiOciSymbols.fnDescriptorAlloc)(envHandle, handle, handleType, 0, NULL); - return dpiError__check(error, status, NULL, action); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, action); } @@ -1314,7 +1441,7 @@ int dpiOci__errorGet(void *handle, uint32_t handleType, uint16_t charsetId, // Wrapper for OCI allocation of memory, only used when debugging memory // allocation. //----------------------------------------------------------------------------- -static void dpiOci__freeMem(void *unused, void *ptr) +static void dpiOci__freeMem(UNUSED void *unused, void *ptr) { char message[40]; @@ -1338,7 +1465,7 @@ int dpiOci__handleAlloc(void *envHandle, void **handle, uint32_t handleType, NULL); if (handleType == DPI_OCI_HTYPE_ERROR && status != DPI_OCI_SUCCESS) return dpiError__set(error, action, DPI_ERR_NO_MEMORY); - return dpiError__check(error, status, NULL, action); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, action); } @@ -1372,9 +1499,10 @@ int dpiOci__intervalGetDaySecond(void *envHandle, int32_t *day, int32_t *hour, DPI_OCI_LOAD_SYMBOL("OCIIntervalGetDaySecond", dpiOciSymbols.fnIntervalGetDaySecond) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnIntervalGetDaySecond)(envHandle, error->handle, day, hour, minute, second, fsecond, interval); - return dpiError__check(error, status, NULL, "get interval components"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "get interval components"); } @@ -1389,9 +1517,10 @@ int dpiOci__intervalGetYearMonth(void *envHandle, int32_t *year, DPI_OCI_LOAD_SYMBOL("OCIIntervalGetYearMonth", dpiOciSymbols.fnIntervalGetYearMonth) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnIntervalGetYearMonth)(envHandle, error->handle, year, month, interval); - return dpiError__check(error, status, NULL, "get interval components"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "get interval components"); } @@ -1407,9 +1536,10 @@ int dpiOci__intervalSetDaySecond(void *envHandle, int32_t day, int32_t hour, DPI_OCI_LOAD_SYMBOL("OCIIntervalSetDaySecond", dpiOciSymbols.fnIntervalSetDaySecond) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnIntervalSetDaySecond)(envHandle, error->handle, day, hour, minute, second, fsecond, interval); - return dpiError__check(error, status, NULL, "set interval components"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "set interval components"); } @@ -1424,9 +1554,10 @@ int dpiOci__intervalSetYearMonth(void *envHandle, int32_t year, int32_t month, DPI_OCI_LOAD_SYMBOL("OCIIntervalSetYearMonth", dpiOciSymbols.fnIntervalSetYearMonth) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnIntervalSetYearMonth)(envHandle, error->handle, year, month, interval); - return dpiError__check(error, status, NULL, "set interval components"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "set interval components"); } @@ -1713,13 +1844,17 @@ static int dpiOci__loadLibValidate(dpiError *error) // determine the OCI client version information if (dpiOci__loadSymbol("OCIClientVersion", (void**) &dpiOciSymbols.fnClientVersion, NULL) < 0) - return dpiError__set(error, "check Oracle Client version", - DPI_ERR_ORACLE_CLIENT_TOO_OLD, 0, 0, 11, 2); + return dpiError__set(error, "load symbol OCIClientVersion", + DPI_ERR_ORACLE_CLIENT_UNSUPPORTED); + memset(&dpiOciLibVersionInfo, 0, sizeof(dpiOciLibVersionInfo)); (*dpiOciSymbols.fnClientVersion)(&dpiOciLibVersionInfo.versionNum, &dpiOciLibVersionInfo.releaseNum, &dpiOciLibVersionInfo.updateNum, &dpiOciLibVersionInfo.portReleaseNum, &dpiOciLibVersionInfo.portUpdateNum); + if (dpiOciLibVersionInfo.versionNum == 0) + return dpiError__set(error, "get OCI client version", + DPI_ERR_ORACLE_CLIENT_UNSUPPORTED); dpiOciLibVersionInfo.fullVersionNum = (uint32_t) DPI_ORACLE_VERSION_TO_NUMBER(dpiOciLibVersionInfo.versionNum, dpiOciLibVersionInfo.releaseNum, @@ -1785,9 +1920,10 @@ int dpiOci__lobClose(dpiLob *lob, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCILobClose", dpiOciSymbols.fnLobClose) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnLobClose)(lob->conn->handle, error->handle, lob->locator); - return dpiError__check(error, status, lob->conn, "close LOB"); + DPI_OCI_CHECK_AND_RETURN(error, status, lob->conn, "close LOB"); } @@ -1802,13 +1938,14 @@ int dpiOci__lobCreateTemporary(dpiLob *lob, dpiError *error) DPI_OCI_LOAD_SYMBOL("OCILobCreateTemporary", dpiOciSymbols.fnLobCreateTemporary) + DPI_OCI_ENSURE_ERROR_HANDLE(error) if (lob->type->oracleTypeNum == DPI_ORACLE_TYPE_BLOB) lobType = DPI_OCI_TEMP_BLOB; else lobType = DPI_OCI_TEMP_CLOB; status = (*dpiOciSymbols.fnLobCreateTemporary)(lob->conn->handle, error->handle, lob->locator, DPI_OCI_DEFAULT, lob->type->charsetForm, lobType, 1, DPI_OCI_DURATION_SESSION); - return dpiError__check(error, status, lob->conn, "create temporary LOB"); + DPI_OCI_CHECK_AND_RETURN(error, status, lob->conn, "create temporary LOB"); } @@ -1821,9 +1958,10 @@ int dpiOci__lobFileExists(dpiLob *lob, int *exists, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCILobFileExists", dpiOciSymbols.fnLobFileExists) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnLobFileExists)(lob->conn->handle, error->handle, lob->locator, exists); - return dpiError__check(error, status, lob->conn, "get file exists"); + DPI_OCI_CHECK_AND_RETURN(error, status, lob->conn, "get file exists"); } @@ -1838,9 +1976,10 @@ int dpiOci__lobFileGetName(dpiLob *lob, char *dirAlias, int status; DPI_OCI_LOAD_SYMBOL("OCILobFileGetName", dpiOciSymbols.fnLobFileGetName) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnLobFileGetName)(lob->env->handle, error->handle, lob->locator, dirAlias, dirAliasLength, name, nameLength); - return dpiError__check(error, status, lob->conn, "get LOB file name"); + DPI_OCI_CHECK_AND_RETURN(error, status, lob->conn, "get LOB file name"); } @@ -1855,9 +1994,10 @@ int dpiOci__lobFileSetName(dpiLob *lob, const char *dirAlias, int status; DPI_OCI_LOAD_SYMBOL("OCILobFileSetName", dpiOciSymbols.fnLobFileSetName) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnLobFileSetName)(lob->env->handle, error->handle, &lob->locator, dirAlias, dirAliasLength, name, nameLength); - return dpiError__check(error, status, lob->conn, "set LOB file name"); + DPI_OCI_CHECK_AND_RETURN(error, status, lob->conn, "set LOB file name"); } @@ -1872,11 +2012,12 @@ int dpiOci__lobFreeTemporary(dpiConn *conn, void *lobLocator, int checkError, DPI_OCI_LOAD_SYMBOL("OCILobFreeTemporary", dpiOciSymbols.fnLobFreeTemporary) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnLobFreeTemporary)(conn->handle, error->handle, lobLocator); - if (checkError) - return dpiError__check(error, status, conn, "free temporary LOB"); - return DPI_SUCCESS; + if (!checkError) + return DPI_SUCCESS; + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "free temporary LOB"); } @@ -1889,9 +2030,10 @@ int dpiOci__lobGetChunkSize(dpiLob *lob, uint32_t *size, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCILobGetChunkSize", dpiOciSymbols.fnLobGetChunkSize) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnLobGetChunkSize)(lob->conn->handle, error->handle, lob->locator, size); - return dpiError__check(error, status, lob->conn, "get chunk size"); + DPI_OCI_CHECK_AND_RETURN(error, status, lob->conn, "get chunk size"); } @@ -1904,9 +2046,10 @@ int dpiOci__lobGetLength2(dpiLob *lob, uint64_t *size, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCILobGetLength2", dpiOciSymbols.fnLobGetLength2) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnLobGetLength2)(lob->conn->handle, error->handle, lob->locator, size); - return dpiError__check(error, status, lob->conn, "get length"); + DPI_OCI_CHECK_AND_RETURN(error, status, lob->conn, "get length"); } @@ -1919,9 +2062,10 @@ int dpiOci__lobIsOpen(dpiLob *lob, int *isOpen, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCILobIsOpen", dpiOciSymbols.fnLobIsOpen) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnLobIsOpen)(lob->conn->handle, error->handle, lob->locator, isOpen); - return dpiError__check(error, status, lob->conn, "check is open"); + DPI_OCI_CHECK_AND_RETURN(error, status, lob->conn, "check is open"); } @@ -1936,11 +2080,12 @@ int dpiOci__lobIsTemporary(dpiLob *lob, int *isTemporary, int checkError, *isTemporary = 0; DPI_OCI_LOAD_SYMBOL("OCILobIsTemporary", dpiOciSymbols.fnLobIsTemporary) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnLobIsTemporary)(lob->env->handle, error->handle, lob->locator, isTemporary); - if (checkError) - return dpiError__check(error, status, lob->conn, "check is temporary"); - return DPI_SUCCESS; + if (!checkError) + return DPI_SUCCESS; + DPI_OCI_CHECK_AND_RETURN(error, status, lob->conn, "check is temporary"); } @@ -1954,9 +2099,10 @@ int dpiOci__lobLocatorAssign(dpiLob *lob, void **copiedHandle, dpiError *error) DPI_OCI_LOAD_SYMBOL("OCILobLocatorAssign", dpiOciSymbols.fnLobLocatorAssign) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnLobLocatorAssign)(lob->conn->handle, error->handle, lob->locator, copiedHandle); - return dpiError__check(error, status, lob->conn, "assign locator"); + DPI_OCI_CHECK_AND_RETURN(error, status, lob->conn, "assign locator"); } @@ -1970,11 +2116,12 @@ int dpiOci__lobOpen(dpiLob *lob, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCILobOpen", dpiOciSymbols.fnLobOpen) + DPI_OCI_ENSURE_ERROR_HANDLE(error) mode = (lob->type->oracleTypeNum == DPI_ORACLE_TYPE_BFILE) ? DPI_OCI_LOB_READONLY : DPI_OCI_LOB_READWRITE; status = (*dpiOciSymbols.fnLobOpen)(lob->conn->handle, error->handle, lob->locator, mode); - return dpiError__check(error, status, lob->conn, "close LOB"); + DPI_OCI_CHECK_AND_RETURN(error, status, lob->conn, "close LOB"); } @@ -1990,13 +2137,14 @@ int dpiOci__lobRead2(dpiLob *lob, uint64_t offset, uint64_t *amountInBytes, int status; DPI_OCI_LOAD_SYMBOL("OCILobRead2", dpiOciSymbols.fnLobRead2) + DPI_OCI_ENSURE_ERROR_HANDLE(error) charsetId = (lob->type->charsetForm == DPI_SQLCS_NCHAR) ? lob->env->ncharsetId : lob->env->charsetId; status = (*dpiOciSymbols.fnLobRead2)(lob->conn->handle, error->handle, lob->locator, amountInBytes, amountInChars, offset, buffer, bufferLength, DPI_OCI_ONE_PIECE, NULL, NULL, charsetId, lob->type->charsetForm); - return dpiError__check(error, status, lob->conn, "read from LOB"); + DPI_OCI_CHECK_AND_RETURN(error, status, lob->conn, "read from LOB"); } @@ -2009,11 +2157,12 @@ int dpiOci__lobTrim2(dpiLob *lob, uint64_t newLength, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCILobTrim2", dpiOciSymbols.fnLobTrim2) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnLobTrim2)(lob->conn->handle, error->handle, lob->locator, newLength); if (status == DPI_OCI_INVALID_HANDLE) return dpiOci__lobCreateTemporary(lob, error); - return dpiError__check(error, status, lob->conn, "trim LOB"); + DPI_OCI_CHECK_AND_RETURN(error, status, lob->conn, "trim LOB"); } @@ -2029,13 +2178,14 @@ int dpiOci__lobWrite2(dpiLob *lob, uint64_t offset, const char *value, int status; DPI_OCI_LOAD_SYMBOL("OCILobWrite2", dpiOciSymbols.fnLobWrite2) + DPI_OCI_ENSURE_ERROR_HANDLE(error) charsetId = (lob->type->charsetForm == DPI_SQLCS_NCHAR) ? lob->env->ncharsetId : lob->env->charsetId; status = (*dpiOciSymbols.fnLobWrite2)(lob->conn->handle, error->handle, lob->locator, &lengthInBytes, &lengthInChars, offset, (void*) value, valueLength, DPI_OCI_ONE_PIECE, NULL, NULL, charsetId, lob->type->charsetForm); - return dpiError__check(error, status, lob->conn, "write to LOB"); + DPI_OCI_CHECK_AND_RETURN(error, status, lob->conn, "write to LOB"); } @@ -2050,11 +2200,12 @@ int dpiOci__memoryAlloc(dpiConn *conn, void **ptr, uint32_t size, *ptr = NULL; DPI_OCI_LOAD_SYMBOL("OCIMemoryAlloc", dpiOciSymbols.fnMemoryAlloc) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnMemoryAlloc)(conn->sessionHandle, error->handle, ptr, DPI_OCI_DURATION_SESSION, size, DPI_OCI_MEMORY_CLEARED); - if (checkError) - return dpiError__check(error, status, conn, "allocate memory"); - return DPI_SUCCESS; + if (!checkError) + return DPI_SUCCESS; + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "allocate memory"); } @@ -2065,6 +2216,7 @@ int dpiOci__memoryAlloc(dpiConn *conn, void **ptr, uint32_t size, int dpiOci__memoryFree(dpiConn *conn, void *ptr, dpiError *error) { DPI_OCI_LOAD_SYMBOL("OCIMemoryFree", dpiOciSymbols.fnMemoryFree) + DPI_OCI_ENSURE_ERROR_HANDLE(error) (*dpiOciSymbols.fnMemoryFree)(conn->sessionHandle, error->handle, ptr); return DPI_SUCCESS; } @@ -2083,10 +2235,11 @@ int dpiOci__nlsCharSetConvert(void *envHandle, uint16_t destCharsetId, DPI_OCI_LOAD_SYMBOL("OCINlsCharSetConvert", dpiOciSymbols.fnNlsCharSetConvert) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnNlsCharSetConvert)(envHandle, error->handle, destCharsetId, dest, destLength, sourceCharsetId, source, sourceLength, resultSize); - return dpiError__check(error, status, NULL, "convert text"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "convert text"); } @@ -2169,9 +2322,10 @@ int dpiOci__nlsNumericInfoGet(void *envHandle, int32_t *value, uint16_t item, DPI_OCI_LOAD_SYMBOL("OCINlsNumericInfoGet", dpiOciSymbols.fnNlsNumericInfoGet) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnNlsNumericInfoGet)(envHandle, error->handle, value, item); - return dpiError__check(error, status, NULL, "get NLS info"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "get NLS info"); } @@ -2185,9 +2339,10 @@ int dpiOci__numberFromInt(const void *value, unsigned int valueLength, int status; DPI_OCI_LOAD_SYMBOL("OCINumberFromInt", dpiOciSymbols.fnNumberFromInt) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnNumberFromInt)(error->handle, value, valueLength, flags, number); - return dpiError__check(error, status, NULL, "number from integer"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "number from integer"); } @@ -2200,9 +2355,10 @@ int dpiOci__numberFromReal(const double value, void *number, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCINumberFromReal", dpiOciSymbols.fnNumberFromReal) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnNumberFromReal)(error->handle, &value, sizeof(double), number); - return dpiError__check(error, status, NULL, "number from real"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "number from real"); } @@ -2216,9 +2372,10 @@ int dpiOci__numberToInt(void *number, void *value, unsigned int valueLength, int status; DPI_OCI_LOAD_SYMBOL("OCINumberToInt", dpiOciSymbols.fnNumberToInt) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnNumberToInt)(error->handle, number, valueLength, flags, value); - return dpiError__check(error, status, NULL, "number to integer"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "number to integer"); } @@ -2231,9 +2388,10 @@ int dpiOci__numberToReal(double *value, void *number, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCINumberToReal", dpiOciSymbols.fnNumberToReal) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnNumberToReal)(error->handle, number, sizeof(double), value); - return dpiError__check(error, status, NULL, "number to real"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "number to real"); } @@ -2247,11 +2405,12 @@ int dpiOci__objectCopy(dpiObject *obj, void *sourceInstance, int status; DPI_OCI_LOAD_SYMBOL("OCIObjectCopy", dpiOciSymbols.fnObjectCopy) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnObjectCopy)(obj->env->handle, error->handle, obj->type->conn->handle, sourceInstance, sourceIndicator, obj->instance, obj->indicator, obj->type->tdo, DPI_OCI_DURATION_SESSION, DPI_OCI_DEFAULT); - return dpiError__check(error, status, obj->type->conn, "copy object"); + DPI_OCI_CHECK_AND_RETURN(error, status, obj->type->conn, "copy object"); } @@ -2259,15 +2418,18 @@ int dpiOci__objectCopy(dpiObject *obj, void *sourceInstance, // dpiOci__objectFree() [INTERNAL] // Wrapper for OCIObjectFree(). //----------------------------------------------------------------------------- -int dpiOci__objectFree(dpiObject *obj, int checkError, dpiError *error) +int dpiOci__objectFree(void *envHandle, void *data, int checkError, + dpiError *error) { int status; DPI_OCI_LOAD_SYMBOL("OCIObjectFree", dpiOciSymbols.fnObjectFree) - status = (*dpiOciSymbols.fnObjectFree)(obj->env->handle, error->handle, - obj->instance, DPI_OCI_DEFAULT); - if (checkError && dpiError__check(error, status, obj->type->conn, - "free instance") < 0) { + DPI_OCI_ENSURE_ERROR_HANDLE(error) + status = (*dpiOciSymbols.fnObjectFree)(envHandle, error->handle, data, + DPI_OCI_DEFAULT); + if (checkError && DPI_OCI_ERROR_OCCURRED(status)) { + dpiError__setFromOCI(error, status, NULL, "free instance"); + // during the attempt to free, PL/SQL records fail with error // "ORA-21602: operation does not support the specified typecode", but // a subsequent attempt will yield error "OCI-21500: internal error @@ -2277,13 +2439,6 @@ int dpiOci__objectFree(dpiObject *obj, int checkError, dpiError *error) return DPI_SUCCESS; return DPI_FAILURE; } - if (obj->freeIndicator) { - status = (*dpiOciSymbols.fnObjectFree)(obj->env->handle, error->handle, - obj->indicator, DPI_OCI_DEFAULT); - if (checkError && dpiError__check(error, status, obj->type->conn, - "free indicator") < 0) - return DPI_FAILURE; - } return DPI_SUCCESS; } @@ -2299,11 +2454,12 @@ int dpiOci__objectGetAttr(dpiObject *obj, dpiObjectAttr *attr, int status; DPI_OCI_LOAD_SYMBOL("OCIObjectGetAttr", dpiOciSymbols.fnObjectGetAttr) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnObjectGetAttr)(obj->env->handle, error->handle, obj->instance, obj->indicator, obj->type->tdo, &attr->name, &attr->nameLength, 1, 0, 0, scalarValueIndicator, valueIndicator, value, tdo); - return dpiError__check(error, status, obj->type->conn, "get attribute"); + DPI_OCI_CHECK_AND_RETURN(error, status, obj->type->conn, "get attribute"); } @@ -2316,9 +2472,10 @@ int dpiOci__objectGetInd(dpiObject *obj, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCIObjectGetInd", dpiOciSymbols.fnObjectGetInd) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnObjectGetInd)(obj->env->handle, error->handle, obj->instance, &obj->indicator); - return dpiError__check(error, status, obj->type->conn, "get indicator"); + DPI_OCI_CHECK_AND_RETURN(error, status, obj->type->conn, "get indicator"); } @@ -2331,10 +2488,11 @@ int dpiOci__objectNew(dpiObject *obj, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCIObjectNew", dpiOciSymbols.fnObjectNew) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnObjectNew)(obj->env->handle, error->handle, obj->type->conn->handle, obj->type->typeCode, obj->type->tdo, NULL, DPI_OCI_DURATION_SESSION, 1, &obj->instance); - return dpiError__check(error, status, obj->type->conn, "create object"); + DPI_OCI_CHECK_AND_RETURN(error, status, obj->type->conn, "create object"); } @@ -2348,10 +2506,11 @@ int dpiOci__objectPin(void *envHandle, void *objRef, void **obj, int status; DPI_OCI_LOAD_SYMBOL("OCIObjectPin", dpiOciSymbols.fnObjectPin) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnObjectPin)(envHandle, error->handle, objRef, NULL, DPI_OCI_PIN_ANY, DPI_OCI_DURATION_SESSION, DPI_OCI_LOCK_NONE, obj); - return dpiError__check(error, status, NULL, "pin reference"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "pin reference"); } @@ -2366,11 +2525,12 @@ int dpiOci__objectSetAttr(dpiObject *obj, dpiObjectAttr *attr, int status; DPI_OCI_LOAD_SYMBOL("OCIObjectSetAttr", dpiOciSymbols.fnObjectSetAttr) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnObjectSetAttr)(obj->env->handle, error->handle, obj->instance, obj->indicator, obj->type->tdo, &attr->name, &attr->nameLength, 1, NULL, 0, scalarValueIndicator, valueIndicator, value); - return dpiError__check(error, status, obj->type->conn, "set attribute"); + DPI_OCI_CHECK_AND_RETURN(error, status, obj->type->conn, "set attribute"); } @@ -2386,10 +2546,11 @@ int dpiOci__passwordChange(dpiConn *conn, const char *userName, int status; DPI_OCI_LOAD_SYMBOL("OCIPasswordChange", dpiOciSymbols.fnPasswordChange) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnPasswordChange)(conn->handle, error->handle, userName, userNameLength, oldPassword, oldPasswordLength, newPassword, newPasswordLength, mode); - return dpiError__check(error, status, conn, "change password"); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "change password"); } @@ -2403,9 +2564,10 @@ int dpiOci__paramGet(const void *handle, uint32_t handleType, void **parameter, int status; DPI_OCI_LOAD_SYMBOL("OCIParamGet", dpiOciSymbols.fnParamGet) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnParamGet)(handle, handleType, error->handle, parameter, pos); - return dpiError__check(error, status, NULL, action); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, action); } @@ -2418,17 +2580,21 @@ int dpiOci__ping(dpiConn *conn, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCIPing", dpiOciSymbols.fnPing) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnPing)(conn->handle, error->handle, DPI_OCI_DEFAULT); - status = dpiError__check(error, status, conn, "ping"); + if (DPI_OCI_ERROR_OCCURRED(status)) { + dpiError__setFromOCI(error, status, conn, "ping"); - // attempting to ping a database earlier than 10g will result in error - // ORA-1010: invalid OCI operation, but that implies a successful ping - // so ignore that error and treat it as a successful operation - if (status < 0 && error->buffer->code == 1010) - return DPI_SUCCESS; + // attempting to ping a database earlier than 10g will result in error + // ORA-1010: invalid OCI operation, but that implies a successful ping + // so ignore that error and treat it as a successful operation + if (error->buffer->code == 1010) + return DPI_SUCCESS; + return DPI_FAILURE; + } - return status; + return DPI_SUCCESS; } @@ -2442,9 +2608,10 @@ int dpiOci__rawAssignBytes(void *envHandle, const char *value, int status; DPI_OCI_LOAD_SYMBOL("OCIRawAssignBytes", dpiOciSymbols.fnRawAssignBytes) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnRawAssignBytes)(envHandle, error->handle, value, valueLength, handle); - return dpiError__check(error, status, NULL, "assign bytes to raw"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "assign bytes to raw"); } @@ -2472,9 +2639,10 @@ int dpiOci__rawResize(void *envHandle, void **handle, uint32_t newSize, int status; DPI_OCI_LOAD_SYMBOL("OCIRawResize", dpiOciSymbols.fnRawResize) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnRawResize)(envHandle, error->handle, newSize, handle); - return dpiError__check(error, status, NULL, "resize raw"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "resize raw"); } @@ -2497,7 +2665,7 @@ int dpiOci__rawSize(void *envHandle, void *handle, uint32_t *size) // Wrapper for OCI allocation of memory, only used when debugging memory // allocation. //----------------------------------------------------------------------------- -static void *dpiOci__reallocMem(void *unused, void *ptr, size_t newSize) +static void *dpiOci__reallocMem(UNUSED void *unused, void *ptr, size_t newSize) { char message[80]; void *newPtr; @@ -2520,12 +2688,13 @@ int dpiOci__rowidToChar(dpiRowid *rowid, char *buffer, uint16_t *bufferSize, int status; DPI_OCI_LOAD_SYMBOL("OCIRowidToChar", dpiOciSymbols.fnRowidToChar) + DPI_OCI_ENSURE_ERROR_HANDLE(error) origSize = *bufferSize; status = (*dpiOciSymbols.fnRowidToChar)(rowid->handle, buffer, bufferSize, error->handle); if (origSize == 0) return DPI_SUCCESS; - return dpiError__check(error, status, NULL, "get rowid as string"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "get rowid as string"); } @@ -2539,9 +2708,10 @@ int dpiOci__serverAttach(dpiConn *conn, const char *connectString, int status; DPI_OCI_LOAD_SYMBOL("OCIServerAttach", dpiOciSymbols.fnServerAttach) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnServerAttach)(conn->serverHandle, error->handle, connectString, (int32_t) connectStringLength, DPI_OCI_DEFAULT); - return dpiError__check(error, status, conn, "server attach"); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "server attach"); } @@ -2554,11 +2724,12 @@ int dpiOci__serverDetach(dpiConn *conn, int checkError, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCIServerDetach", dpiOciSymbols.fnServerDetach) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnServerDetach)(conn->serverHandle, error->handle, DPI_OCI_DEFAULT); - if (checkError) - return dpiError__check(error, status, conn, "detatch from server"); - return DPI_SUCCESS; + if (!checkError) + return DPI_SUCCESS; + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "detatch from server"); } @@ -2571,6 +2742,7 @@ int dpiOci__serverRelease(dpiConn *conn, char *buffer, uint32_t bufferSize, { int status; + DPI_OCI_ENSURE_ERROR_HANDLE(error) if (conn->env->versionInfo->versionNum < 18) { DPI_OCI_LOAD_SYMBOL("OCIServerRelease", dpiOciSymbols.fnServerRelease) status = (*dpiOciSymbols.fnServerRelease)(conn->handle, error->handle, @@ -2582,7 +2754,7 @@ int dpiOci__serverRelease(dpiConn *conn, char *buffer, uint32_t bufferSize, buffer, bufferSize, DPI_OCI_HTYPE_SVCCTX, version, DPI_OCI_DEFAULT); } - return dpiError__check(error, status, conn, "get server version"); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "get server version"); } @@ -2596,9 +2768,10 @@ int dpiOci__sessionBegin(dpiConn *conn, uint32_t credentialType, int status; DPI_OCI_LOAD_SYMBOL("OCISessionBegin", dpiOciSymbols.fnSessionBegin) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSessionBegin)(conn->handle, error->handle, conn->sessionHandle, credentialType, mode); - return dpiError__check(error, status, conn, "begin session"); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "begin session"); } @@ -2611,11 +2784,12 @@ int dpiOci__sessionEnd(dpiConn *conn, int checkError, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCISessionEnd", dpiOciSymbols.fnSessionEnd) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSessionEnd)(conn->handle, error->handle, conn->sessionHandle, DPI_OCI_DEFAULT); - if (checkError) - return dpiError__check(error, status, conn, "end session"); - return DPI_SUCCESS; + if (!checkError) + return DPI_SUCCESS; + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "end session"); } @@ -2631,10 +2805,11 @@ int dpiOci__sessionGet(void *envHandle, void **handle, void *authInfo, int status; DPI_OCI_LOAD_SYMBOL("OCISessionGet", dpiOciSymbols.fnSessionGet) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSessionGet)(envHandle, error->handle, handle, authInfo, connectString, connectStringLength, tag, tagLength, outTag, outTagLength, found, mode); - return dpiError__check(error, status, NULL, "get session"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "get session"); } @@ -2652,12 +2827,13 @@ int dpiOci__sessionPoolCreate(dpiPool *pool, const char *connectString, DPI_OCI_LOAD_SYMBOL("OCISessionPoolCreate", dpiOciSymbols.fnSessionPoolCreate) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSessionPoolCreate)(pool->env->handle, error->handle, pool->handle, (char**) &pool->name, &pool->nameLength, connectString, connectStringLength, minSessions, maxSessions, sessionIncrement, userName, userNameLength, password, passwordLength, mode); - return dpiError__check(error, status, NULL, "create pool"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "create pool"); } @@ -2673,6 +2849,7 @@ int dpiOci__sessionPoolDestroy(dpiPool *pool, uint32_t mode, int checkError, DPI_OCI_LOAD_SYMBOL("OCISessionPoolDestroy", dpiOciSymbols.fnSessionPoolDestroy) + DPI_OCI_ENSURE_ERROR_HANDLE(error) // clear the pool handle immediately so that no further attempts are made // to use the pool while the pool is being closed; if the pool close fails, @@ -2681,10 +2858,9 @@ int dpiOci__sessionPoolDestroy(dpiPool *pool, uint32_t mode, int checkError, pool->handle = NULL; status = (*dpiOciSymbols.fnSessionPoolDestroy)(handle, error->handle, mode); - if (checkError && - dpiError__check(error, status, NULL, "destroy pool") < 0) { + if (checkError && DPI_OCI_ERROR_OCCURRED(status)) { pool->handle = handle; - return DPI_FAILURE; + return dpiError__setFromOCI(error, status, NULL, "destroy pool"); } dpiOci__handleFree(handle, DPI_OCI_HTYPE_SPOOL); return DPI_SUCCESS; @@ -2701,11 +2877,12 @@ int dpiOci__sessionRelease(dpiConn *conn, const char *tag, uint32_t tagLength, int status; DPI_OCI_LOAD_SYMBOL("OCISessionRelease", dpiOciSymbols.fnSessionRelease) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSessionRelease)(conn->handle, error->handle, tag, tagLength, mode); - if (checkError) - return dpiError__check(error, status, conn, "release session"); - return DPI_SUCCESS; + if (!checkError) + return DPI_SUCCESS; + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "release session"); } @@ -2720,9 +2897,51 @@ int dpiOci__shardingKeyColumnAdd(void *shardingKey, void *col, uint32_t colLen, DPI_OCI_LOAD_SYMBOL("OCIShardingKeyColumnAdd", dpiOciSymbols.fnShardingKeyColumnAdd) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnShardingKeyColumnAdd)(shardingKey, error->handle, col, colLen, colType, DPI_OCI_DEFAULT); - return dpiError__check(error, status, NULL, "add sharding column"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "add sharding column"); +} + + +//----------------------------------------------------------------------------- +// dpiOci__sodaBulkInsert() [INTERNAL] +// Wrapper for OCISodaBulkInsert(). +//----------------------------------------------------------------------------- +int dpiOci__sodaBulkInsert(dpiSodaColl *coll, void **documents, + uint32_t numDocuments, void *outputOptions, uint32_t mode, + dpiError *error) +{ + int status; + + DPI_OCI_LOAD_SYMBOL("OCISodaBulkInsert", dpiOciSymbols.fnSodaBulkInsert) + DPI_OCI_ENSURE_ERROR_HANDLE(error) + status = (*dpiOciSymbols.fnSodaBulkInsert)(coll->db->conn->handle, + coll->handle, documents, numDocuments, outputOptions, + error->handle, mode); + DPI_OCI_CHECK_AND_RETURN(error, status, coll->db->conn, + "insert multiple documents"); +} + + +//----------------------------------------------------------------------------- +// dpiOci__sodaBulkInsertAndGet() [INTERNAL] +// Wrapper for OCISodaBulkInsert(). +//----------------------------------------------------------------------------- +int dpiOci__sodaBulkInsertAndGet(dpiSodaColl *coll, void **documents, + uint32_t numDocuments, void *outputOptions, uint32_t mode, + dpiError *error) +{ + int status; + + DPI_OCI_LOAD_SYMBOL("OCISodaBulkInsertAndGet", + dpiOciSymbols.fnSodaBulkInsertAndGet) + DPI_OCI_ENSURE_ERROR_HANDLE(error) + status = (*dpiOciSymbols.fnSodaBulkInsertAndGet)(coll->db->conn->handle, + coll->handle, documents, numDocuments, outputOptions, + error->handle, mode); + DPI_OCI_CHECK_AND_RETURN(error, status, coll->db->conn, + "insert (and get) multiple documents"); } @@ -2738,10 +2957,12 @@ int dpiOci__sodaCollCreateWithMetadata(dpiSodaDb *db, const char *name, DPI_OCI_LOAD_SYMBOL("OCISodaCollCreateWithMetadata", dpiOciSymbols.fnSodaCollCreateWithMetadata) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSodaCollCreateWithMetadata)(db->conn->handle, name, nameLength, metadata, metadataLength, handle, error->handle, mode); - return dpiError__check(error, status, db->conn, "create SODA collection"); + DPI_OCI_CHECK_AND_RETURN(error, status, db->conn, + "create SODA collection"); } @@ -2755,9 +2976,10 @@ int dpiOci__sodaCollDrop(dpiSodaColl *coll, int *isDropped, uint32_t mode, int status; DPI_OCI_LOAD_SYMBOL("OCISodaCollDrop", dpiOciSymbols.fnSodaCollDrop) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSodaCollDrop)(coll->db->conn->handle, coll->handle, isDropped, error->handle, mode); - return dpiError__check(error, status, coll->db->conn, + DPI_OCI_CHECK_AND_RETURN(error, status, coll->db->conn, "drop SODA collection"); } @@ -2772,13 +2994,14 @@ int dpiOci__sodaCollGetNext(dpiConn *conn, void *cursorHandle, int status; DPI_OCI_LOAD_SYMBOL("OCISodaCollGetNext", dpiOciSymbols.fnSodaCollGetNext) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSodaCollGetNext)(conn->handle, cursorHandle, collectionHandle, error->handle, mode); if (status == DPI_OCI_NO_DATA) { *collectionHandle = NULL; return DPI_SUCCESS; } - return dpiError__check(error, status, conn, "get next collection"); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "get next collection"); } @@ -2793,9 +3016,10 @@ int dpiOci__sodaCollList(dpiSodaDb *db, const char *startingName, int status; DPI_OCI_LOAD_SYMBOL("OCISodaCollList", dpiOciSymbols.fnSodaCollList) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSodaCollList)(db->conn->handle, startingName, startingNameLength, handle, error->handle, mode); - return dpiError__check(error, status, db->conn, + DPI_OCI_CHECK_AND_RETURN(error, status, db->conn, "get SODA collection cursor"); } @@ -2810,9 +3034,10 @@ int dpiOci__sodaCollOpen(dpiSodaDb *db, const char *name, uint32_t nameLength, int status; DPI_OCI_LOAD_SYMBOL("OCISodaCollOpen", dpiOciSymbols.fnSodaCollOpen) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSodaCollOpen)(db->conn->handle, name, nameLength, handle, error->handle, mode); - return dpiError__check(error, status, db->conn, "open SODA collection"); + DPI_OCI_CHECK_AND_RETURN(error, status, db->conn, "open SODA collection"); } @@ -2827,9 +3052,11 @@ int dpiOci__sodaDataGuideGet(dpiSodaColl *coll, void **handle, uint32_t mode, DPI_OCI_LOAD_SYMBOL("OCISodaDataGuideGet", dpiOciSymbols.fnSodaDataGuideGet) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSodaDataGuideGet)(coll->db->conn->handle, coll->handle, DPI_OCI_DEFAULT, handle, error->handle, mode); - if (dpiError__check(error, status, coll->db->conn, "get data guide") < 0) { + if (DPI_OCI_ERROR_OCCURRED(status)) { + dpiError__setFromOCI(error, status, coll->db->conn, "get data guide"); if (error->buffer->code != 24801) return DPI_FAILURE; *handle = NULL; @@ -2848,9 +3075,10 @@ int dpiOci__sodaDocCount(dpiSodaColl *coll, void *options, uint32_t mode, int status; DPI_OCI_LOAD_SYMBOL("OCISodaDocCount", dpiOciSymbols.fnSodaDocCount) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSodaDocCount)(coll->db->conn->handle, coll->handle, options, count, error->handle, mode); - return dpiError__check(error, status, coll->db->conn, + DPI_OCI_CHECK_AND_RETURN(error, status, coll->db->conn, "get document count"); } @@ -2865,13 +3093,14 @@ int dpiOci__sodaDocGetNext(dpiSodaDocCursor *cursor, void **handle, int status; DPI_OCI_LOAD_SYMBOL("OCISodaDocGetNext", dpiOciSymbols.fnSodaDocGetNext) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSodaDocGetNext)(cursor->coll->db->conn->handle, cursor->handle, handle, error->handle, mode); if (status == DPI_OCI_NO_DATA) { *handle = NULL; return DPI_SUCCESS; } - return dpiError__check(error, status, cursor->coll->db->conn, + DPI_OCI_CHECK_AND_RETURN(error, status, cursor->coll->db->conn, "get next document"); } @@ -2886,13 +3115,14 @@ int dpiOci__sodaFind(dpiSodaColl *coll, const void *options, uint32_t flags, int status; DPI_OCI_LOAD_SYMBOL("OCISodaFind", dpiOciSymbols.fnSodaFind) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSodaFind)(coll->db->conn->handle, coll->handle, options, flags, handle, error->handle, mode); if (status == DPI_OCI_NO_DATA) { *handle = NULL; return DPI_SUCCESS; } - return dpiError__check(error, status, coll->db->conn, + DPI_OCI_CHECK_AND_RETURN(error, status, coll->db->conn, "find SODA documents"); } @@ -2907,13 +3137,15 @@ int dpiOci__sodaFindOne(dpiSodaColl *coll, const void *options, uint32_t flags, int status; DPI_OCI_LOAD_SYMBOL("OCISodaFindOne", dpiOciSymbols.fnSodaFindOne) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSodaFindOne)(coll->db->conn->handle, coll->handle, options, flags, handle, error->handle, mode); if (status == DPI_OCI_NO_DATA) { *handle = NULL; return DPI_SUCCESS; } - return dpiError__check(error, status, coll->db->conn, "get SODA document"); + DPI_OCI_CHECK_AND_RETURN(error, status, coll->db->conn, + "get SODA document"); } @@ -2927,9 +3159,10 @@ int dpiOci__sodaIndexCreate(dpiSodaColl *coll, const char *indexSpec, int status; DPI_OCI_LOAD_SYMBOL("OCISodaIndexCreate", dpiOciSymbols.fnSodaIndexCreate) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSodaIndexCreate)(coll->db->conn->handle, coll->handle, indexSpec, indexSpecLength, error->handle, mode); - return dpiError__check(error, status, coll->db->conn, "create index"); + DPI_OCI_CHECK_AND_RETURN(error, status, coll->db->conn, "create index"); } @@ -2943,9 +3176,10 @@ int dpiOci__sodaIndexDrop(dpiSodaColl *coll, const char *name, int status; DPI_OCI_LOAD_SYMBOL("OCISodaIndexDrop", dpiOciSymbols.fnSodaIndexDrop) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSodaIndexDrop)(coll->db->conn->handle, name, nameLength, isDropped, error->handle, mode); - return dpiError__check(error, status, coll->db->conn, "drop index"); + DPI_OCI_CHECK_AND_RETURN(error, status, coll->db->conn, "drop index"); } @@ -2959,9 +3193,10 @@ int dpiOci__sodaInsert(dpiSodaColl *coll, void *handle, uint32_t mode, int status; DPI_OCI_LOAD_SYMBOL("OCISodaInsert", dpiOciSymbols.fnSodaInsert) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSodaInsert)(coll->db->conn->handle, coll->handle, handle, error->handle, mode); - return dpiError__check(error, status, coll->db->conn, + DPI_OCI_CHECK_AND_RETURN(error, status, coll->db->conn, "insert SODA document"); } @@ -2977,9 +3212,10 @@ int dpiOci__sodaInsertAndGet(dpiSodaColl *coll, void **handle, uint32_t mode, DPI_OCI_LOAD_SYMBOL("OCISodaInsertAndGet", dpiOciSymbols.fnSodaInsertAndGet) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSodaInsertAndGet)(coll->db->conn->handle, coll->handle, handle, error->handle, mode); - return dpiError__check(error, status, coll->db->conn, + DPI_OCI_CHECK_AND_RETURN(error, status, coll->db->conn, "insert and get SODA document"); } @@ -2994,10 +3230,12 @@ int dpiOci__sodaOperKeysSet(const dpiSodaOperOptions *options, void *handle, int status; DPI_OCI_LOAD_SYMBOL("OCISodaOperKeysSet", dpiOciSymbols.fnSodaOperKeysSet) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSodaOperKeysSet)(handle, options->keys, options->keyLengths, options->numKeys, error->handle, DPI_OCI_DEFAULT); - return dpiError__check(error, status, NULL, "set operation options keys"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, + "set operation options keys"); } @@ -3011,9 +3249,10 @@ int dpiOci__sodaRemove(dpiSodaColl *coll, void *options, uint32_t mode, int status; DPI_OCI_LOAD_SYMBOL("OCISodaRemove", dpiOciSymbols.fnSodaRemove) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSodaRemove)(coll->db->conn->handle, coll->handle, options, count, error->handle, mode); - return dpiError__check(error, status, coll->db->conn, + DPI_OCI_CHECK_AND_RETURN(error, status, coll->db->conn, "remove documents from SODA collection"); } @@ -3028,9 +3267,10 @@ int dpiOci__sodaReplOne(dpiSodaColl *coll, const void *options, void *handle, int status; DPI_OCI_LOAD_SYMBOL("OCISodaReplOne", dpiOciSymbols.fnSodaReplOne) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSodaReplOne)(coll->db->conn->handle, coll->handle, options, handle, isReplaced, error->handle, mode); - return dpiError__check(error, status, coll->db->conn, + DPI_OCI_CHECK_AND_RETURN(error, status, coll->db->conn, "replace SODA document"); } @@ -3046,9 +3286,10 @@ int dpiOci__sodaReplOneAndGet(dpiSodaColl *coll, const void *options, DPI_OCI_LOAD_SYMBOL("OCISodaReplOneAndGet", dpiOciSymbols.fnSodaReplOneAndGet) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSodaReplOneAndGet)(coll->db->conn->handle, coll->handle, options, handle, isReplaced, error->handle, mode); - return dpiError__check(error, status, coll->db->conn, + DPI_OCI_CHECK_AND_RETURN(error, status, coll->db->conn, "replace and get SODA document"); } @@ -3063,9 +3304,10 @@ int dpiOci__stmtExecute(dpiStmt *stmt, uint32_t numIters, uint32_t mode, int status; DPI_OCI_LOAD_SYMBOL("OCIStmtExecute", dpiOciSymbols.fnStmtExecute) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnStmtExecute)(stmt->conn->handle, stmt->handle, error->handle, numIters, 0, 0, 0, mode); - return dpiError__check(error, status, stmt->conn, "execute"); + DPI_OCI_CHECK_AND_RETURN(error, status, stmt->conn, "execute"); } @@ -3079,13 +3321,16 @@ int dpiOci__stmtFetch2(dpiStmt *stmt, uint32_t numRows, uint16_t fetchMode, int status; DPI_OCI_LOAD_SYMBOL("OCIStmtFetch2", dpiOciSymbols.fnStmtFetch2) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnStmtFetch2)(stmt->handle, error->handle, numRows, fetchMode, offset, DPI_OCI_DEFAULT); - if (status == DPI_OCI_NO_DATA || fetchMode == DPI_MODE_FETCH_LAST) + if (status == DPI_OCI_NO_DATA || fetchMode == DPI_MODE_FETCH_LAST) { stmt->hasRowsToFetch = 0; - else if (dpiError__check(error, status, stmt->conn, "fetch") < 0) - return DPI_FAILURE; - else stmt->hasRowsToFetch = 1; + } else if (DPI_OCI_ERROR_OCCURRED(status)) { + return dpiError__setFromOCI(error, status, stmt->conn, "fetch"); + } else { + stmt->hasRowsToFetch = 1; + } return DPI_SUCCESS; } @@ -3102,6 +3347,7 @@ int dpiOci__stmtGetBindInfo(dpiStmt *stmt, uint32_t size, uint32_t startLoc, int status; DPI_OCI_LOAD_SYMBOL("OCIStmtGetBindInfo", dpiOciSymbols.fnStmtGetBindInfo) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnStmtGetBindInfo)(stmt->handle, error->handle, size, startLoc, numFound, names, nameLengths, indNames, indNameLengths, isDuplicate, bindHandles); @@ -3109,7 +3355,7 @@ int dpiOci__stmtGetBindInfo(dpiStmt *stmt, uint32_t size, uint32_t startLoc, *numFound = 0; return DPI_SUCCESS; } - return dpiError__check(error, status, stmt->conn, "get bind info"); + DPI_OCI_CHECK_AND_RETURN(error, status, stmt->conn, "get bind info"); } @@ -3124,13 +3370,14 @@ int dpiOci__stmtGetNextResult(dpiStmt *stmt, void **handle, dpiError *error) DPI_OCI_LOAD_SYMBOL("OCIStmtGetNextResult", dpiOciSymbols.fnStmtGetNextResult) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnStmtGetNextResult)(stmt->handle, error->handle, handle, &returnType, DPI_OCI_DEFAULT); if (status == DPI_OCI_NO_DATA) { *handle = NULL; return DPI_SUCCESS; } - return dpiError__check(error, status, stmt->conn, "get next result"); + DPI_OCI_CHECK_AND_RETURN(error, status, stmt->conn, "get next result"); } @@ -3144,12 +3391,13 @@ int dpiOci__stmtPrepare2(dpiStmt *stmt, const char *sql, uint32_t sqlLength, int status; DPI_OCI_LOAD_SYMBOL("OCIStmtPrepare2", dpiOciSymbols.fnStmtPrepare2) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnStmtPrepare2)(stmt->conn->handle, &stmt->handle, error->handle, sql, sqlLength, tag, tagLength, DPI_OCI_NTV_SYNTAX, DPI_OCI_DEFAULT); - if (dpiError__check(error, status, stmt->conn, "prepare SQL") < 0) { + if (DPI_OCI_ERROR_OCCURRED(status)) { stmt->handle = NULL; - return DPI_FAILURE; + return dpiError__setFromOCI(error, status, stmt->conn, "prepare SQL"); } return DPI_SUCCESS; @@ -3178,11 +3426,12 @@ int dpiOci__stmtRelease(dpiStmt *stmt, const char *tag, uint32_t tagLength, } DPI_OCI_LOAD_SYMBOL("OCIStmtRelease", dpiOciSymbols.fnStmtRelease) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnStmtRelease)(stmt->handle, error->handle, tag, tagLength, mode); - if (checkError) - return dpiError__check(error, status, stmt->conn, "release statement"); - return DPI_SUCCESS; + if (!checkError) + return DPI_SUCCESS; + DPI_OCI_CHECK_AND_RETURN(error, status, stmt->conn, "release statement"); } @@ -3197,9 +3446,10 @@ int dpiOci__stringAssignText(void *envHandle, const char *value, DPI_OCI_LOAD_SYMBOL("OCIStringAssignText", dpiOciSymbols.fnStringAssignText) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnStringAssignText)(envHandle, error->handle, value, valueLength, handle); - return dpiError__check(error, status, NULL, "assign to string"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "assign to string"); } @@ -3227,9 +3477,10 @@ int dpiOci__stringResize(void *envHandle, void **handle, uint32_t newSize, int status; DPI_OCI_LOAD_SYMBOL("OCIStringResize", dpiOciSymbols.fnStringResize) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnStringResize)(envHandle, error->handle, newSize, handle); - return dpiError__check(error, status, NULL, "resize string"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "resize string"); } @@ -3251,15 +3502,17 @@ int dpiOci__stringSize(void *envHandle, void *handle, uint32_t *size) // dpiOci__subscriptionRegister() [INTERNAL] // Wrapper for OCISubscriptionRegister(). //----------------------------------------------------------------------------- -int dpiOci__subscriptionRegister(dpiConn *conn, void **handle, dpiError *error) +int dpiOci__subscriptionRegister(dpiConn *conn, void **handle, uint32_t mode, + dpiError *error) { int status; DPI_OCI_LOAD_SYMBOL("OCISubscriptionRegister", dpiOciSymbols.fnSubscriptionRegister) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnSubscriptionRegister)(conn->handle, handle, 1, - error->handle, DPI_OCI_DEFAULT); - return dpiError__check(error, status, conn, "register"); + error->handle, mode); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "register"); } @@ -3270,13 +3523,17 @@ int dpiOci__subscriptionRegister(dpiConn *conn, void **handle, dpiError *error) int dpiOci__subscriptionUnRegister(dpiConn *conn, dpiSubscr *subscr, dpiError *error) { + uint32_t mode; int status; DPI_OCI_LOAD_SYMBOL("OCISubscriptionUnRegister", dpiOciSymbols.fnSubscriptionUnRegister) + DPI_OCI_ENSURE_ERROR_HANDLE(error) + mode = (subscr->clientInitiated) ? DPI_OCI_SECURE_NOTIFICATION : + DPI_OCI_DEFAULT; status = (*dpiOciSymbols.fnSubscriptionUnRegister)(conn->handle, - subscr->handle, error->handle, DPI_OCI_DEFAULT); - return dpiError__check(error, status, conn, "unregister"); + subscr->handle, error->handle, mode); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "unregister"); } @@ -3289,9 +3546,10 @@ int dpiOci__tableDelete(dpiObject *obj, int32_t index, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCITableDelete", dpiOciSymbols.fnTableDelete) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnTableDelete)(obj->env->handle, error->handle, index, obj->instance); - return dpiError__check(error, status, obj->type->conn, "delete element"); + DPI_OCI_CHECK_AND_RETURN(error, status, obj->type->conn, "delete element"); } @@ -3305,9 +3563,11 @@ int dpiOci__tableExists(dpiObject *obj, int32_t index, int *exists, int status; DPI_OCI_LOAD_SYMBOL("OCITableExists", dpiOciSymbols.fnTableExists) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnTableExists)(obj->env->handle, error->handle, obj->instance, index, exists); - return dpiError__check(error, status, obj->type->conn, "get index exists"); + DPI_OCI_CHECK_AND_RETURN(error, status, obj->type->conn, + "get index exists"); } @@ -3320,9 +3580,11 @@ int dpiOci__tableFirst(dpiObject *obj, int32_t *index, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCITableFirst", dpiOciSymbols.fnTableFirst) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnTableFirst)(obj->env->handle, error->handle, obj->instance, index); - return dpiError__check(error, status, obj->type->conn, "get first index"); + DPI_OCI_CHECK_AND_RETURN(error, status, obj->type->conn, + "get first index"); } @@ -3335,9 +3597,10 @@ int dpiOci__tableLast(dpiObject *obj, int32_t *index, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCITableLast", dpiOciSymbols.fnTableLast) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnTableLast)(obj->env->handle, error->handle, obj->instance, index); - return dpiError__check(error, status, obj->type->conn, "get last index"); + DPI_OCI_CHECK_AND_RETURN(error, status, obj->type->conn, "get last index"); } @@ -3351,9 +3614,10 @@ int dpiOci__tableNext(dpiObject *obj, int32_t index, int32_t *nextIndex, int status; DPI_OCI_LOAD_SYMBOL("OCITableNext", dpiOciSymbols.fnTableNext) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnTableNext)(obj->env->handle, error->handle, index, obj->instance, nextIndex, exists); - return dpiError__check(error, status, obj->type->conn, "get next index"); + DPI_OCI_CHECK_AND_RETURN(error, status, obj->type->conn, "get next index"); } @@ -3367,9 +3631,10 @@ int dpiOci__tablePrev(dpiObject *obj, int32_t index, int32_t *prevIndex, int status; DPI_OCI_LOAD_SYMBOL("OCITablePrev", dpiOciSymbols.fnTablePrev) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnTablePrev)(obj->env->handle, error->handle, index, obj->instance, prevIndex, exists); - return dpiError__check(error, status, obj->type->conn, "get prev index"); + DPI_OCI_CHECK_AND_RETURN(error, status, obj->type->conn, "get prev index"); } @@ -3382,9 +3647,10 @@ int dpiOci__tableSize(dpiObject *obj, int32_t *size, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCITableSize", dpiOciSymbols.fnTableSize) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnTableSize)(obj->env->handle, error->handle, obj->instance, size); - return dpiError__check(error, status, obj->type->conn, "get size"); + DPI_OCI_CHECK_AND_RETURN(error, status, obj->type->conn, "get size"); } @@ -3431,7 +3697,7 @@ int dpiOci__threadKeyInit(void *envHandle, void *errorHandle, void **key, DPI_OCI_LOAD_SYMBOL("OCIThreadKeyInit", dpiOciSymbols.fnThreadKeyInit) status = (*dpiOciSymbols.fnThreadKeyInit)(envHandle, errorHandle, key, destroyFunc); - return dpiError__check(error, status, NULL, "initialize thread key"); + DPI_OCI_CHECK_AND_RETURN(error, status, NULL, "initialize thread key"); } @@ -3462,9 +3728,10 @@ int dpiOci__transCommit(dpiConn *conn, uint32_t flags, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCITransCommit", dpiOciSymbols.fnTransCommit) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnTransCommit)(conn->handle, error->handle, flags); - return dpiError__check(error, status, conn, "commit"); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "commit"); } @@ -3477,10 +3744,11 @@ int dpiOci__transPrepare(dpiConn *conn, int *commitNeeded, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCITransPrepare", dpiOciSymbols.fnTransPrepare) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnTransPrepare)(conn->handle, error->handle, DPI_OCI_DEFAULT); *commitNeeded = (status == DPI_OCI_SUCCESS); - return dpiError__check(error, status, conn, "prepare transaction"); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "prepare transaction"); } @@ -3493,11 +3761,12 @@ int dpiOci__transRollback(dpiConn *conn, int checkError, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCITransRollback", dpiOciSymbols.fnTransRollback) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnTransRollback)(conn->handle, error->handle, DPI_OCI_DEFAULT); - if (checkError) - return dpiError__check(error, status, conn, "rollback"); - return DPI_SUCCESS; + if (!checkError) + return DPI_SUCCESS; + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "rollback"); } @@ -3510,9 +3779,29 @@ int dpiOci__transStart(dpiConn *conn, dpiError *error) int status; DPI_OCI_LOAD_SYMBOL("OCITransStart", dpiOciSymbols.fnTransStart) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnTransStart)(conn->handle, error->handle, 0, DPI_OCI_TRANS_NEW); - return dpiError__check(error, status, conn, "start transaction"); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "start transaction"); +} + + +//----------------------------------------------------------------------------- +// dpiOci__typeByName() [INTERNAL] +// Wrapper for OCITypeByName(). +//----------------------------------------------------------------------------- +int dpiOci__typeByName(dpiConn *conn, const char *schema, + uint32_t schemaLength, const char *name, uint32_t nameLength, + void **tdo, dpiError *error) +{ + int status; + + DPI_OCI_LOAD_SYMBOL("OCITypeByName", dpiOciSymbols.fnTypeByName) + DPI_OCI_ENSURE_ERROR_HANDLE(error) + status = (*dpiOciSymbols.fnTypeByName)(conn->env->handle, error->handle, + conn->handle, schema, schemaLength, name, nameLength, NULL, 0, + DPI_OCI_DURATION_SESSION, DPI_OCI_TYPEGET_ALL, tdo); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "get type by name"); } @@ -3526,9 +3815,9 @@ int dpiOci__typeByFullName(dpiConn *conn, const char *name, int status; DPI_OCI_LOAD_SYMBOL("OCITypeByFullName", dpiOciSymbols.fnTypeByFullName) + DPI_OCI_ENSURE_ERROR_HANDLE(error) status = (*dpiOciSymbols.fnTypeByFullName)(conn->env->handle, error->handle, conn->handle, name, nameLength, NULL, 0, DPI_OCI_DURATION_SESSION, DPI_OCI_TYPEGET_ALL, tdo); - return dpiError__check(error, status, conn, "get type by full name"); + DPI_OCI_CHECK_AND_RETURN(error, status, conn, "get type by full name"); } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiOracleType.c b/vendor/github.com/godror/godror/odpi/src/dpiOracleType.c similarity index 99% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiOracleType.c rename to vendor/github.com/godror/godror/odpi/src/dpiOracleType.c index 7397d8f5253..ee307a7d995 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiOracleType.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiOracleType.c @@ -298,12 +298,14 @@ static dpiOracleTypeNum dpiOracleType__convertFromOracle(uint16_t typeCode, if (charsetForm == DPI_SQLCS_NCHAR) return DPI_ORACLE_TYPE_NVARCHAR; return DPI_ORACLE_TYPE_VARCHAR; + case DPI_SQLT_INT: case DPI_SQLT_FLT: case DPI_SQLT_NUM: case DPI_SQLT_PDN: case DPI_SQLT_VNU: case DPI_SQLT_BFLOAT: case DPI_SQLT_BDOUBLE: + case DPI_OCI_TYPECODE_SMALLINT: return DPI_ORACLE_TYPE_NUMBER; case DPI_SQLT_DAT: case DPI_SQLT_ODT: @@ -315,8 +317,8 @@ static dpiOracleTypeNum dpiOracleType__convertFromOracle(uint16_t typeCode, if (charsetForm == DPI_SQLCS_NCHAR) return DPI_ORACLE_TYPE_NCHAR; return DPI_ORACLE_TYPE_CHAR; - case DPI_SQLT_INT: - case DPI_OCI_TYPECODE_SMALLINT: + case DPI_OCI_TYPECODE_BINARY_INTEGER: + case DPI_OCI_TYPECODE_PLS_INTEGER: return DPI_ORACLE_TYPE_NATIVE_INT; case DPI_SQLT_IBFLOAT: return DPI_ORACLE_TYPE_NATIVE_FLOAT; @@ -344,6 +346,7 @@ static dpiOracleTypeNum dpiOracleType__convertFromOracle(uint16_t typeCode, case DPI_SQLT_BFILE: return DPI_ORACLE_TYPE_BFILE; case DPI_SQLT_RDD: + case DPI_OCI_TYPECODE_ROWID: return DPI_ORACLE_TYPE_ROWID; case DPI_SQLT_RSET: return DPI_ORACLE_TYPE_STMT; @@ -352,8 +355,10 @@ static dpiOracleTypeNum dpiOracleType__convertFromOracle(uint16_t typeCode, case DPI_SQLT_INTERVAL_YM: return DPI_ORACLE_TYPE_INTERVAL_YM; case DPI_SQLT_LNG: + case DPI_OCI_TYPECODE_LONG: return DPI_ORACLE_TYPE_LONG_VARCHAR; case DPI_SQLT_LBI: + case DPI_OCI_TYPECODE_LONG_RAW: return DPI_ORACLE_TYPE_LONG_RAW; } return (dpiOracleTypeNum) 0; @@ -497,4 +502,3 @@ int dpiOracleType__populateTypeInfo(dpiConn *conn, void *handle, return DPI_SUCCESS; } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiPool.c b/vendor/github.com/godror/godror/odpi/src/dpiPool.c similarity index 96% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiPool.c rename to vendor/github.com/godror/godror/odpi/src/dpiPool.c index 9d237767163..58f21e5efc9 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiPool.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiPool.c @@ -30,6 +30,7 @@ int dpiPool__acquireConnection(dpiPool *pool, const char *userName, if (dpiGen__allocate(DPI_HTYPE_CONN, pool->env, (void**) &tempConn, error) < 0) return DPI_FAILURE; + error->env = pool->env; // create the connection if (dpiConn__create(tempConn, pool->env->context, userName, userNameLength, @@ -52,7 +53,7 @@ int dpiPool__acquireConnection(dpiPool *pool, const char *userName, static int dpiPool__checkConnected(dpiPool *pool, const char *fnName, dpiError *error) { - if (dpiGen__startPublicFn(pool, DPI_HTYPE_POOL, fnName, 1, error) < 0) + if (dpiGen__startPublicFn(pool, DPI_HTYPE_POOL, fnName, error) < 0) return DPI_FAILURE; if (!pool->handle) return dpiError__set(error, "check pool", DPI_ERR_NOT_CONNECTED); @@ -158,6 +159,17 @@ static int dpiPool__create(dpiPool *pool, const char *userName, return DPI_FAILURE; } + // set the maximum number of sessions per shard (valid in 18.3 and higher) + if (pool->env->versionInfo->versionNum > 18 || + (pool->env->versionInfo->versionNum == 18 && + pool->env->versionInfo->releaseNum >= 3)) { + if (dpiOci__attrSet(pool->handle, DPI_OCI_HTYPE_SPOOL, (void*) + &createParams->maxSessionsPerShard, 0, + DPI_OCI_ATTR_SPOOL_MAX_PER_SHARD, + "set max sessions per shard", error) < 0) + return DPI_FAILURE; + } + // set reamining attributes directly pool->homogeneous = createParams->homogeneous; pool->externalAuth = createParams->externalAuth; @@ -359,7 +371,7 @@ int dpiPool_create(const dpiContext *context, const char *userName, dpiError error; // validate parameters - if (dpiGen__startPublicFn(context, DPI_HTYPE_CONTEXT, __func__, 0, + if (dpiGen__startPublicFn(context, DPI_HTYPE_CONTEXT, __func__, &error) < 0) return dpiGen__endPublicFn(context, DPI_FAILURE, &error); DPI_CHECK_PTR_AND_LENGTH(context, userName) @@ -387,7 +399,7 @@ int dpiPool_create(const dpiContext *context, const char *userName, return dpiGen__endPublicFn(context, DPI_FAILURE, &error); // initialize environment - if (dpiEnv__init(tempPool->env, context, commonParams, &error) < 0) { + if (dpiEnv__init(tempPool->env, context, commonParams, NULL, &error) < 0) { dpiPool__free(tempPool, &error); return dpiGen__endPublicFn(context, DPI_FAILURE, &error); } @@ -403,8 +415,7 @@ int dpiPool_create(const dpiContext *context, const char *userName, createParams->outPoolName = tempPool->name; createParams->outPoolNameLength = tempPool->nameLength; *pool = tempPool; - dpiHandlePool__release(tempPool->env->errorHandles, error.handle, &error); - error.handle = NULL; + dpiHandlePool__release(tempPool->env->errorHandles, &error.handle); return dpiGen__endPublicFn(context, DPI_SUCCESS, &error); } @@ -573,4 +584,3 @@ int dpiPool_setWaitTimeout(dpiPool *pool, uint32_t value) return dpiPool__setAttributeUint(pool, DPI_OCI_ATTR_SPOOL_WAIT_TIMEOUT, value, __func__); } - diff --git a/vendor/github.com/godror/godror/odpi/src/dpiQueue.c b/vendor/github.com/godror/godror/odpi/src/dpiQueue.c new file mode 100644 index 00000000000..9c2f39a9a82 --- /dev/null +++ b/vendor/github.com/godror/godror/odpi/src/dpiQueue.c @@ -0,0 +1,560 @@ +//----------------------------------------------------------------------------- +// Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. +// This program is free software: you can modify it and/or redistribute it +// under the terms of: +// +// (i) the Universal Permissive License v 1.0 or at your option, any +// later version (http://oss.oracle.com/licenses/upl); and/or +// +// (ii) the Apache License v 2.0. (http://www.apache.org/licenses/LICENSE-2.0) +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// dpiQueue.c +// Implementation of AQ queues. +//----------------------------------------------------------------------------- + +#include "dpiImpl.h" + +// forward declarations of internal functions only used in this file +static int dpiQueue__allocateBuffer(dpiQueue *queue, uint32_t numElements, + dpiError *error); +static int dpiQueue__deq(dpiQueue *queue, uint32_t *numProps, + dpiMsgProps **props, dpiError *error); +static void dpiQueue__freeBuffer(dpiQueue *queue, dpiError *error); +static int dpiQueue__getPayloadTDO(dpiQueue *queue, void **tdo, + dpiError *error); + + +//----------------------------------------------------------------------------- +// dpiQueue__allocate() [INTERNAL] +// Allocate and initialize a queue. +//----------------------------------------------------------------------------- +int dpiQueue__allocate(dpiConn *conn, const char *name, uint32_t nameLength, + dpiObjectType *payloadType, dpiQueue **queue, dpiError *error) +{ + dpiQueue *tempQueue; + char *buffer; + + // allocate handle; store reference to the connection that created it + if (dpiGen__allocate(DPI_HTYPE_QUEUE, conn->env, (void**) &tempQueue, + error) < 0) + return DPI_FAILURE; + dpiGen__setRefCount(conn, error, 1); + tempQueue->conn = conn; + + // store payload type, which is either an object type or NULL (meaning that + // RAW payloads are being enqueued and dequeued) + if (payloadType) { + dpiGen__setRefCount(payloadType, error, 1); + tempQueue->payloadType = payloadType; + } + + // allocate space for the name of the queue; OCI requires a NULL-terminated + // string so allocate enough space to store the NULL terminator; UTF-16 + // encoded strings are not currently supported + if (dpiUtils__allocateMemory(1, nameLength + 1, 0, "queue name", + (void**) &buffer, error) < 0) { + dpiQueue__free(tempQueue, error); + return DPI_FAILURE; + } + memcpy(buffer, name, nameLength); + buffer[nameLength] = '\0'; + tempQueue->name = buffer; + + *queue = tempQueue; + return DPI_SUCCESS; +} + + +//----------------------------------------------------------------------------- +// dpiQueue__allocateBuffer() [INTERNAL] +// Ensure there is enough space in the buffer for the specified number of +// elements. +//----------------------------------------------------------------------------- +static int dpiQueue__allocateBuffer(dpiQueue *queue, uint32_t numElements, + dpiError *error) +{ + dpiQueue__freeBuffer(queue, error); + queue->buffer.numElements = numElements; + if (dpiUtils__allocateMemory(numElements, sizeof(dpiMsgProps*), 1, + "allocate msg props array", (void**) &queue->buffer.props, + error) < 0) + return DPI_FAILURE; + if (dpiUtils__allocateMemory(numElements, sizeof(void*), 1, + "allocate OCI handles array", (void**) &queue->buffer.handles, + error) < 0) + return DPI_FAILURE; + if (dpiUtils__allocateMemory(numElements, sizeof(void*), 1, + "allocate OCI instances array", (void**) &queue->buffer.instances, + error) < 0) + return DPI_FAILURE; + if (dpiUtils__allocateMemory(numElements, sizeof(void*), 1, + "allocate OCI indicators array", + (void**) &queue->buffer.indicators, error) < 0) + return DPI_FAILURE; + if (!queue->payloadType) { + if (dpiUtils__allocateMemory(numElements, sizeof(int16_t), 1, + "allocate OCI raw indicators array", + (void**) &queue->buffer.rawIndicators, error) < 0) + return DPI_FAILURE; + } + if (dpiUtils__allocateMemory(numElements, sizeof(void*), 1, + "allocate message ids array", (void**) &queue->buffer.msgIds, + error) < 0) + return DPI_FAILURE; + + return DPI_SUCCESS; +} + + +//----------------------------------------------------------------------------- +// dpiQueue__check() [INTERNAL] +// Determine if the queue is available to use. +//----------------------------------------------------------------------------- +static int dpiQueue__check(dpiQueue *queue, const char *fnName, + dpiError *error) +{ + if (dpiGen__startPublicFn(queue, DPI_HTYPE_QUEUE, fnName, error) < 0) + return DPI_FAILURE; + if (!queue->conn->handle || queue->conn->closing) + return dpiError__set(error, "check connection", DPI_ERR_NOT_CONNECTED); + return DPI_SUCCESS; +} + + +//----------------------------------------------------------------------------- +// dpiQueue__createDeqOptions() [INTERNAL] +// Create the dequeue options object that will be used for performing +// dequeues against the queue. +//----------------------------------------------------------------------------- +static int dpiQueue__createDeqOptions(dpiQueue *queue, dpiError *error) +{ + dpiDeqOptions *tempOptions; + + if (dpiGen__allocate(DPI_HTYPE_DEQ_OPTIONS, queue->env, + (void**) &tempOptions, error) < 0) + return DPI_FAILURE; + if (dpiDeqOptions__create(tempOptions, queue->conn, error) < 0) { + dpiDeqOptions__free(tempOptions, error); + return DPI_FAILURE; + } + + queue->deqOptions = tempOptions; + return DPI_SUCCESS; +} + + +//----------------------------------------------------------------------------- +// dpiQueue__createEnqOptions() [INTERNAL] +// Create the dequeue options object that will be used for performing +// dequeues against the queue. +//----------------------------------------------------------------------------- +static int dpiQueue__createEnqOptions(dpiQueue *queue, dpiError *error) +{ + dpiEnqOptions *tempOptions; + + if (dpiGen__allocate(DPI_HTYPE_ENQ_OPTIONS, queue->env, + (void**) &tempOptions, error) < 0) + return DPI_FAILURE; + if (dpiEnqOptions__create(tempOptions, queue->conn, error) < 0) { + dpiEnqOptions__free(tempOptions, error); + return DPI_FAILURE; + } + + queue->enqOptions = tempOptions; + return DPI_SUCCESS; +} + + +//----------------------------------------------------------------------------- +// dpiQueue__deq() [INTERNAL] +// Perform a dequeue of up to the specified number of properties. +//----------------------------------------------------------------------------- +static int dpiQueue__deq(dpiQueue *queue, uint32_t *numProps, + dpiMsgProps **props, dpiError *error) +{ + dpiMsgProps *prop; + void *payloadTDO; + uint32_t i; + + // create dequeue options, if necessary + if (!queue->deqOptions && dpiQueue__createDeqOptions(queue, error) < 0) + return DPI_FAILURE; + + // allocate buffer, if necessary + if (queue->buffer.numElements < *numProps && + dpiQueue__allocateBuffer(queue, *numProps, error) < 0) + return DPI_FAILURE; + + // populate buffer + for (i = 0; i < *numProps; i++) { + prop = queue->buffer.props[i]; + + // create new message properties, if applicable + if (!prop) { + if (dpiMsgProps__allocate(queue->conn, &prop, error) < 0) + return DPI_FAILURE; + queue->buffer.props[i] = prop; + } + + // create payload object, if applicable + if (queue->payloadType && !prop->payloadObj && + dpiObject__allocate(queue->payloadType, NULL, NULL, NULL, + &prop->payloadObj, error) < 0) + return DPI_FAILURE; + + // set OCI arrays + queue->buffer.handles[i] = prop->handle; + if (queue->payloadType) { + queue->buffer.instances[i] = prop->payloadObj->instance; + queue->buffer.indicators[i] = prop->payloadObj->indicator; + } else { + queue->buffer.instances[i] = prop->payloadRaw; + queue->buffer.indicators[i] = &queue->buffer.rawIndicators[i]; + } + queue->buffer.msgIds[i] = prop->msgIdRaw; + + } + + // perform dequeue + if (dpiQueue__getPayloadTDO(queue, &payloadTDO, error) < 0) + return DPI_FAILURE; + if (dpiOci__aqDeqArray(queue->conn, queue->name, queue->deqOptions->handle, + numProps, queue->buffer.handles, payloadTDO, + queue->buffer.instances, queue->buffer.indicators, + queue->buffer.msgIds, error) < 0) { + if (error->buffer->code != 25228) + return DPI_FAILURE; + error->buffer->offset = (uint16_t) *numProps; + } + + // transfer message properties to destination array + for (i = 0; i < *numProps; i++) { + props[i] = queue->buffer.props[i]; + queue->buffer.props[i] = NULL; + if (!queue->payloadType) + props[i]->payloadRaw = queue->buffer.instances[i]; + props[i]->msgIdRaw = queue->buffer.msgIds[i]; + } + + return DPI_SUCCESS; +} + + +//----------------------------------------------------------------------------- +// dpiQueue__enq() [INTERNAL] +// Perform an enqueue of the specified properties. +//----------------------------------------------------------------------------- +static int dpiQueue__enq(dpiQueue *queue, uint32_t numProps, + dpiMsgProps **props, dpiError *error) +{ + void *payloadTDO; + uint32_t i; + + // if no messages are being enqueued, nothing to do! + if (numProps == 0) + return DPI_SUCCESS; + + // create enqueue options, if necessary + if (!queue->enqOptions && dpiQueue__createEnqOptions(queue, error) < 0) + return DPI_FAILURE; + + // allocate buffer, if necessary + if (queue->buffer.numElements < numProps && + dpiQueue__allocateBuffer(queue, numProps, error) < 0) + return DPI_FAILURE; + + // populate buffer + for (i = 0; i < numProps; i++) { + + // perform checks + if (!props[i]->payloadObj && !props[i]->payloadRaw) + return dpiError__set(error, "check payload", + DPI_ERR_QUEUE_NO_PAYLOAD); + if ((queue->payloadType && !props[i]->payloadObj) || + (!queue->payloadType && props[i]->payloadObj)) + return dpiError__set(error, "check payload", + DPI_ERR_QUEUE_WRONG_PAYLOAD_TYPE); + if (queue->payloadType && props[i]->payloadObj && + queue->payloadType->tdo != props[i]->payloadObj->type->tdo) + return dpiError__set(error, "check payload", + DPI_ERR_WRONG_TYPE, + props[i]->payloadObj->type->schemaLength, + props[i]->payloadObj->type->schema, + props[i]->payloadObj->type->nameLength, + props[i]->payloadObj->type->name, + queue->payloadType->schemaLength, + queue->payloadType->schema, + queue->payloadType->nameLength, + queue->payloadType->name); + + // set OCI arrays + queue->buffer.handles[i] = props[i]->handle; + if (queue->payloadType) { + queue->buffer.instances[i] = props[i]->payloadObj->instance; + queue->buffer.indicators[i] = props[i]->payloadObj->indicator; + } else { + queue->buffer.instances[i] = props[i]->payloadRaw; + queue->buffer.indicators[i] = &queue->buffer.rawIndicators[i]; + } + queue->buffer.msgIds[i] = props[i]->msgIdRaw; + + } + + // perform enqueue + if (dpiQueue__getPayloadTDO(queue, &payloadTDO, error) < 0) + return DPI_FAILURE; + if (numProps == 1) { + if (dpiOci__aqEnq(queue->conn, queue->name, queue->enqOptions->handle, + queue->buffer.handles[0], payloadTDO, queue->buffer.instances, + queue->buffer.indicators, queue->buffer.msgIds, error) < 0) + return DPI_FAILURE; + } else { + if (dpiOci__aqEnqArray(queue->conn, queue->name, + queue->enqOptions->handle, &numProps, queue->buffer.handles, + payloadTDO, queue->buffer.instances, queue->buffer.indicators, + queue->buffer.msgIds, error) < 0) { + error->buffer->offset = (uint16_t) numProps; + return DPI_FAILURE; + } + } + + // transfer message ids back to message properties + for (i = 0; i < numProps; i++) + props[i]->msgIdRaw = queue->buffer.msgIds[i]; + + return DPI_SUCCESS; +} + + +//----------------------------------------------------------------------------- +// dpiQueue__free() [INTERNAL] +// Free the memory for a queue. +//----------------------------------------------------------------------------- +void dpiQueue__free(dpiQueue *queue, dpiError *error) +{ + if (queue->conn) { + dpiGen__setRefCount(queue->conn, error, -1); + queue->conn = NULL; + } + if (queue->payloadType) { + dpiGen__setRefCount(queue->payloadType, error, -1); + queue->payloadType = NULL; + } + if (queue->name) { + dpiUtils__freeMemory((void*) queue->name); + queue->name = NULL; + } + if (queue->deqOptions) { + dpiGen__setRefCount(queue->deqOptions, error, -1); + queue->deqOptions = NULL; + } + if (queue->enqOptions) { + dpiGen__setRefCount(queue->enqOptions, error, -1); + queue->enqOptions = NULL; + } + dpiQueue__freeBuffer(queue, error); + dpiUtils__freeMemory(queue); +} + + +//----------------------------------------------------------------------------- +// dpiQueue__freeBuffer() [INTERNAL] +// Free the memory areas in the queue buffer. +//----------------------------------------------------------------------------- +static void dpiQueue__freeBuffer(dpiQueue *queue, dpiError *error) +{ + dpiQueueBuffer *buffer = &queue->buffer; + uint32_t i; + + if (buffer->props) { + for (i = 0; i < buffer->numElements; i++) { + if (buffer->props[i]) { + dpiGen__setRefCount(buffer->props[i], error, -1); + buffer->props[i] = NULL; + } + } + dpiUtils__freeMemory(buffer->props); + buffer->props = NULL; + } + if (buffer->handles) { + dpiUtils__freeMemory(buffer->handles); + buffer->handles = NULL; + } + if (buffer->instances) { + dpiUtils__freeMemory(buffer->instances); + buffer->instances = NULL; + } + if (buffer->indicators) { + dpiUtils__freeMemory(buffer->indicators); + buffer->indicators = NULL; + } + if (buffer->rawIndicators) { + dpiUtils__freeMemory(buffer->rawIndicators); + buffer->rawIndicators = NULL; + } + if (buffer->msgIds) { + dpiUtils__freeMemory(buffer->msgIds); + buffer->msgIds = NULL; + } +} + + +//----------------------------------------------------------------------------- +// dpiQueue__getPayloadTDO() [INTERNAL] +// Acquire the TDO to use for the payload. This will either be the TDO of the +// object type (if one was specified when the queue was created) or it will be +// the RAW TDO cached on the connection. +//----------------------------------------------------------------------------- +static int dpiQueue__getPayloadTDO(dpiQueue *queue, void **tdo, + dpiError *error) +{ + if (queue->payloadType) { + *tdo = queue->payloadType->tdo; + } else { + if (dpiConn__getRawTDO(queue->conn, error) < 0) + return DPI_FAILURE; + *tdo = queue->conn->rawTDO; + } + return DPI_SUCCESS; +} + + +//----------------------------------------------------------------------------- +// dpiQueue_addRef() [PUBLIC] +// Add a reference to the queue. +//----------------------------------------------------------------------------- +int dpiQueue_addRef(dpiQueue *queue) +{ + return dpiGen__addRef(queue, DPI_HTYPE_QUEUE, __func__); +} + + +//----------------------------------------------------------------------------- +// dpiQueue_deqMany() [PUBLIC] +// Dequeue multiple messages from the queue. +//----------------------------------------------------------------------------- +int dpiQueue_deqMany(dpiQueue *queue, uint32_t *numProps, dpiMsgProps **props) +{ + dpiError error; + int status; + + if (dpiQueue__check(queue, __func__, &error) < 0) + return dpiGen__endPublicFn(queue, DPI_FAILURE, &error); + DPI_CHECK_PTR_NOT_NULL(queue, numProps) + DPI_CHECK_PTR_NOT_NULL(queue, props) + status = dpiQueue__deq(queue, numProps, props, &error); + return dpiGen__endPublicFn(queue, status, &error); +} + + +//----------------------------------------------------------------------------- +// dpiQueue_deqOne() [PUBLIC] +// Dequeue a single message from the queue. +//----------------------------------------------------------------------------- +int dpiQueue_deqOne(dpiQueue *queue, dpiMsgProps **props) +{ + uint32_t numProps = 1; + dpiError error; + + if (dpiQueue__check(queue, __func__, &error) < 0) + return dpiGen__endPublicFn(queue, DPI_FAILURE, &error); + DPI_CHECK_PTR_NOT_NULL(queue, props) + if (dpiQueue__deq(queue, &numProps, props, &error) < 0) + return dpiGen__endPublicFn(queue, DPI_FAILURE, &error); + if (numProps == 0) + *props = NULL; + return dpiGen__endPublicFn(queue, DPI_SUCCESS, &error); +} + + +//----------------------------------------------------------------------------- +// dpiQueue_enqMany() [PUBLIC] +// Enqueue multiple message to the queue. +//----------------------------------------------------------------------------- +int dpiQueue_enqMany(dpiQueue *queue, uint32_t numProps, dpiMsgProps **props) +{ + dpiError error; + uint32_t i; + int status; + + // validate parameters + if (dpiQueue__check(queue, __func__, &error) < 0) + return dpiGen__endPublicFn(queue, DPI_FAILURE, &error); + DPI_CHECK_PTR_NOT_NULL(queue, props) + for (i = 0; i < numProps; i++) { + if (dpiGen__checkHandle(props[i], DPI_HTYPE_MSG_PROPS, + "check message properties", &error) < 0) + return dpiGen__endPublicFn(queue, DPI_FAILURE, &error); + } + status = dpiQueue__enq(queue, numProps, props, &error); + return dpiGen__endPublicFn(queue, status, &error); +} + + +//----------------------------------------------------------------------------- +// dpiQueue_enqOne() [PUBLIC] +// Enqueue a single message to the queue. +//----------------------------------------------------------------------------- +int dpiQueue_enqOne(dpiQueue *queue, dpiMsgProps *props) +{ + dpiError error; + int status; + + if (dpiQueue__check(queue, __func__, &error) < 0) + return dpiGen__endPublicFn(queue, DPI_FAILURE, &error); + if (dpiGen__checkHandle(props, DPI_HTYPE_MSG_PROPS, + "check message properties", &error) < 0) + return dpiGen__endPublicFn(queue, DPI_FAILURE, &error); + status = dpiQueue__enq(queue, 1, &props, &error); + return dpiGen__endPublicFn(queue, status, &error); +} + + +//----------------------------------------------------------------------------- +// dpiQueue_getDeqOptions() [PUBLIC] +// Return the dequeue options associated with the queue. If no dequeue +// options are currently associated with the queue, create them first. +//----------------------------------------------------------------------------- +int dpiQueue_getDeqOptions(dpiQueue *queue, dpiDeqOptions **options) +{ + dpiError error; + + if (dpiGen__startPublicFn(queue, DPI_HTYPE_QUEUE, __func__, &error) < 0) + return DPI_FAILURE; + DPI_CHECK_PTR_NOT_NULL(queue, options) + if (!queue->deqOptions && dpiQueue__createDeqOptions(queue, &error) < 0) + return dpiGen__endPublicFn(queue, DPI_FAILURE, &error); + *options = queue->deqOptions; + return dpiGen__endPublicFn(queue, DPI_SUCCESS, &error); +} + + +//----------------------------------------------------------------------------- +// dpiQueue_getEnqOptions() [PUBLIC] +// Return the enqueue options associated with the queue. If no enqueue +// options are currently associated with the queue, create them first. +//----------------------------------------------------------------------------- +int dpiQueue_getEnqOptions(dpiQueue *queue, dpiEnqOptions **options) +{ + dpiError error; + + if (dpiGen__startPublicFn(queue, DPI_HTYPE_QUEUE, __func__, &error) < 0) + return DPI_FAILURE; + DPI_CHECK_PTR_NOT_NULL(queue, options) + if (!queue->enqOptions && dpiQueue__createEnqOptions(queue, &error) < 0) + return dpiGen__endPublicFn(queue, DPI_FAILURE, &error); + *options = queue->enqOptions; + return dpiGen__endPublicFn(queue, DPI_SUCCESS, &error); +} + + +//----------------------------------------------------------------------------- +// dpiQueue_release() [PUBLIC] +// Release a reference to the queue. +//----------------------------------------------------------------------------- +int dpiQueue_release(dpiQueue *queue) +{ + return dpiGen__release(queue, DPI_HTYPE_QUEUE, __func__); +} diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiRowid.c b/vendor/github.com/godror/godror/odpi/src/dpiRowid.c similarity index 99% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiRowid.c rename to vendor/github.com/godror/godror/odpi/src/dpiRowid.c index f3de644deba..9bda49e7cd1 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiRowid.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiRowid.c @@ -78,8 +78,7 @@ int dpiRowid_getStringValue(dpiRowid *rowid, const char **value, dpiError error; uint16_t i; - if (dpiGen__startPublicFn(rowid, DPI_HTYPE_ROWID, __func__, 1, - &error) < 0) + if (dpiGen__startPublicFn(rowid, DPI_HTYPE_ROWID, __func__, &error) < 0) return dpiGen__endPublicFn(rowid, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(rowid, value) DPI_CHECK_PTR_NOT_NULL(rowid, valueLength) @@ -133,4 +132,3 @@ int dpiRowid_release(dpiRowid *rowid) { return dpiGen__release(rowid, DPI_HTYPE_ROWID, __func__); } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiSodaColl.c b/vendor/github.com/godror/godror/odpi/src/dpiSodaColl.c similarity index 84% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiSodaColl.c rename to vendor/github.com/godror/godror/odpi/src/dpiSodaColl.c index a874e4b3f7e..b0a0ded7c34 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiSodaColl.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiSodaColl.c @@ -57,7 +57,7 @@ int dpiSodaColl__allocate(dpiSodaDb *db, void *handle, dpiSodaColl **coll, static int dpiSodaColl__check(dpiSodaColl *coll, const char *fnName, dpiError *error) { - if (dpiGen__startPublicFn(coll, DPI_HTYPE_SODA_COLL, fnName, 1, error) < 0) + if (dpiGen__startPublicFn(coll, DPI_HTYPE_SODA_COLL, fnName, error) < 0) return DPI_FAILURE; if (!coll->db->conn->handle || coll->db->conn->closing) return dpiError__set(error, "check connection", DPI_ERR_NOT_CONNECTED); @@ -255,6 +255,85 @@ static int dpiSodaColl__getDocCount(dpiSodaColl *coll, } +//----------------------------------------------------------------------------- +// dpiSodaColl__insertMany() [INTERNAL] +// Insert multiple documents into the collection and return handles to the +// newly created documents, if desired. +//----------------------------------------------------------------------------- +static int dpiSodaColl__insertMany(dpiSodaColl *coll, uint32_t numDocs, + void **docHandles, uint32_t flags, dpiSodaDoc **insertedDocs, + dpiError *error) +{ + void *optionsHandle; + uint32_t i, j, mode; + uint64_t docCount; + int status; + + // create OCI output options handle + if (dpiOci__handleAlloc(coll->env->handle, &optionsHandle, + DPI_OCI_HTYPE_SODA_OUTPUT_OPTIONS, + "allocate SODA output options handle", error) < 0) + return DPI_FAILURE; + + // determine mode to pass + mode = DPI_OCI_DEFAULT; + if (flags & DPI_SODA_FLAGS_ATOMIC_COMMIT) + mode |= DPI_OCI_SODA_ATOMIC_COMMIT; + + // perform actual bulk insert + if (insertedDocs) { + status = dpiOci__sodaBulkInsertAndGet(coll, docHandles, numDocs, + optionsHandle, mode, error); + } else { + status = dpiOci__sodaBulkInsert(coll, docHandles, numDocs, + optionsHandle, mode, error); + } + + // on failure, determine the number of documents that were successfully + // inserted and store that information in the error buffer + if (status < 0) { + dpiOci__attrGet(optionsHandle, DPI_OCI_HTYPE_SODA_OUTPUT_OPTIONS, + (void*) &docCount, 0, DPI_OCI_ATTR_SODA_DOC_COUNT, + NULL, error); + error->buffer->offset = (uint16_t) docCount; + } + dpiOci__handleFree(optionsHandle, DPI_OCI_HTYPE_SODA_OUTPUT_OPTIONS); + + // on failure, if using the "AndGet" variant, any document handles that + // were created need to be freed + if (insertedDocs && status < 0) { + for (i = 0; i < numDocs; i++) { + if (docHandles[i]) { + dpiOci__handleFree(docHandles[i], DPI_OCI_HTYPE_SODA_DOCUMENT); + docHandles[i] = NULL; + } + } + } + if (status < 0) + return DPI_FAILURE; + + // return document handles, if desired + if (insertedDocs) { + for (i = 0; i < numDocs; i++) { + if (dpiSodaDoc__allocate(coll->db, docHandles[i], &insertedDocs[i], + error) < 0) { + for (j = 0; j < i; j++) { + dpiSodaDoc__free(insertedDocs[j], error); + insertedDocs[j] = NULL; + } + for (j = i; j < numDocs; j++) { + dpiOci__handleFree(docHandles[i], + DPI_OCI_HTYPE_SODA_DOCUMENT); + } + return DPI_FAILURE; + } + } + } + + return DPI_SUCCESS; +} + + //----------------------------------------------------------------------------- // dpiSodaColl__remove() [INTERNAL] // Internal method for removing documents from a collection. @@ -584,6 +663,53 @@ int dpiSodaColl_getName(dpiSodaColl *coll, const char **value, } +//----------------------------------------------------------------------------- +// dpiSodaColl_insertMany() [PUBLIC] +// Insert multiple documents into the collection and return handles to the +// newly created documents, if desired. +//----------------------------------------------------------------------------- +int dpiSodaColl_insertMany(dpiSodaColl *coll, uint32_t numDocs, + dpiSodaDoc **docs, uint32_t flags, dpiSodaDoc **insertedDocs) +{ + void **docHandles; + dpiError error; + uint32_t i; + int status; + + // validate parameters + if (dpiSodaColl__check(coll, __func__, &error) < 0) + return dpiGen__endPublicFn(coll, DPI_FAILURE, &error); + DPI_CHECK_PTR_NOT_NULL(coll, docs) + if (numDocs == 0) { + dpiError__set(&error, "check num documents", DPI_ERR_ARRAY_SIZE_ZERO); + return dpiGen__endPublicFn(coll, DPI_FAILURE, &error); + } + for (i = 0; i < numDocs; i++) { + if (dpiGen__checkHandle(docs[i], DPI_HTYPE_SODA_DOC, "check document", + &error) < 0) + return dpiGen__endPublicFn(coll, DPI_FAILURE, &error); + } + + // bulk insert is only supported with Oracle Client 18.5+ + if (dpiUtils__checkClientVersion(coll->env->versionInfo, 18, 5, + &error) < 0) + return dpiGen__endPublicFn(coll, DPI_FAILURE, &error); + + // create and populate array to hold document handles + if (dpiUtils__allocateMemory(numDocs, sizeof(void*), 1, + "allocate document handles", (void**) &docHandles, &error) < 0) + return dpiGen__endPublicFn(coll, DPI_FAILURE, &error); + for (i = 0; i < numDocs; i++) + docHandles[i] = docs[i]->handle; + + // perform bulk insert + status = dpiSodaColl__insertMany(coll, numDocs, docHandles, flags, + insertedDocs, &error); + dpiUtils__freeMemory(docHandles); + return dpiGen__endPublicFn(coll, status, &error); +} + + //----------------------------------------------------------------------------- // dpiSodaColl_insertOne() [PUBLIC] // Insert a document into the collection and return a handle to the newly @@ -684,4 +810,3 @@ int dpiSodaColl_replaceOne(dpiSodaColl *coll, replacedDoc, &error); return dpiGen__endPublicFn(coll, status, &error); } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiSodaCollCursor.c b/vendor/github.com/godror/godror/odpi/src/dpiSodaCollCursor.c similarity index 99% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiSodaCollCursor.c rename to vendor/github.com/godror/godror/odpi/src/dpiSodaCollCursor.c index 2356b7b9cf9..f4e91a427cb 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiSodaCollCursor.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiSodaCollCursor.c @@ -43,7 +43,7 @@ int dpiSodaCollCursor__allocate(dpiSodaDb *db, void *handle, static int dpiSodaCollCursor__check(dpiSodaCollCursor *cursor, const char *fnName, dpiError *error) { - if (dpiGen__startPublicFn(cursor, DPI_HTYPE_SODA_COLL_CURSOR, fnName, 1, + if (dpiGen__startPublicFn(cursor, DPI_HTYPE_SODA_COLL_CURSOR, fnName, error) < 0) return DPI_FAILURE; if (!cursor->handle) @@ -142,4 +142,3 @@ int dpiSodaCollCursor_release(dpiSodaCollCursor *cursor) { return dpiGen__release(cursor, DPI_HTYPE_SODA_COLL_CURSOR, __func__); } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiSodaDb.c b/vendor/github.com/godror/godror/odpi/src/dpiSodaDb.c similarity index 99% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiSodaDb.c rename to vendor/github.com/godror/godror/odpi/src/dpiSodaDb.c index f6c5cacaf30..0e1605a3507 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiSodaDb.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiSodaDb.c @@ -23,7 +23,7 @@ static int dpiSodaDb__checkConnected(dpiSodaDb *db, const char *fnName, dpiError *error) { - if (dpiGen__startPublicFn(db, DPI_HTYPE_SODA_DB, fnName, 1, error) < 0) + if (dpiGen__startPublicFn(db, DPI_HTYPE_SODA_DB, fnName, error) < 0) return DPI_FAILURE; if (!db->conn->handle || db->conn->closing) return dpiError__set(error, "check connection", DPI_ERR_NOT_CONNECTED); @@ -201,7 +201,7 @@ int dpiSodaDb_createCollection(dpiSodaDb *db, const char *name, //----------------------------------------------------------------------------- int dpiSodaDb_createDocument(dpiSodaDb *db, const char *key, uint32_t keyLength, const char *content, uint32_t contentLength, - const char *mediaType, uint32_t mediaTypeLength, uint32_t flags, + const char *mediaType, uint32_t mediaTypeLength, UNUSED uint32_t flags, dpiSodaDoc **doc) { int detectEncoding; @@ -429,4 +429,3 @@ int dpiSodaDb_release(dpiSodaDb *db) { return dpiGen__release(db, DPI_HTYPE_SODA_DB, __func__); } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiSodaDoc.c b/vendor/github.com/godror/godror/odpi/src/dpiSodaDoc.c similarity index 99% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiSodaDoc.c rename to vendor/github.com/godror/godror/odpi/src/dpiSodaDoc.c index 1b144ee7a6a..b009e33a44a 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiSodaDoc.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiSodaDoc.c @@ -43,7 +43,7 @@ int dpiSodaDoc__allocate(dpiSodaDb *db, void *handle, dpiSodaDoc **doc, static int dpiSodaDoc__check(dpiSodaDoc *doc, const char *fnName, dpiError *error) { - if (dpiGen__startPublicFn(doc, DPI_HTYPE_SODA_DOC, fnName, 1, error) < 0) + if (dpiGen__startPublicFn(doc, DPI_HTYPE_SODA_DOC, fnName, error) < 0) return DPI_FAILURE; if (!doc->db->conn->handle || doc->db->conn->closing) return dpiError__set(error, "check connection", DPI_ERR_NOT_CONNECTED); @@ -229,4 +229,3 @@ int dpiSodaDoc_release(dpiSodaDoc *doc) { return dpiGen__release(doc, DPI_HTYPE_SODA_DOC, __func__); } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiSodaDocCursor.c b/vendor/github.com/godror/godror/odpi/src/dpiSodaDocCursor.c similarity index 99% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiSodaDocCursor.c rename to vendor/github.com/godror/godror/odpi/src/dpiSodaDocCursor.c index a7d7999b43b..9bfd2bdbeea 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiSodaDocCursor.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiSodaDocCursor.c @@ -43,7 +43,7 @@ int dpiSodaDocCursor__allocate(dpiSodaColl *coll, void *handle, static int dpiSodaDocCursor__check(dpiSodaDocCursor *cursor, const char *fnName, dpiError *error) { - if (dpiGen__startPublicFn(cursor, DPI_HTYPE_SODA_DOC_CURSOR, fnName, 1, + if (dpiGen__startPublicFn(cursor, DPI_HTYPE_SODA_DOC_CURSOR, fnName, error) < 0) return DPI_FAILURE; if (!cursor->handle) @@ -142,4 +142,3 @@ int dpiSodaDocCursor_release(dpiSodaDocCursor *cursor) { return dpiGen__release(cursor, DPI_HTYPE_SODA_DOC_CURSOR, __func__); } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiStmt.c b/vendor/github.com/godror/godror/odpi/src/dpiStmt.c similarity index 95% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiStmt.c rename to vendor/github.com/godror/godror/odpi/src/dpiStmt.c index 6cfd01fa187..cd3520b93b0 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiStmt.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiStmt.c @@ -212,9 +212,9 @@ static int dpiStmt__bind(dpiStmt *stmt, dpiVar *var, int addReference, //----------------------------------------------------------------------------- static int dpiStmt__check(dpiStmt *stmt, const char *fnName, dpiError *error) { - if (dpiGen__startPublicFn(stmt, DPI_HTYPE_STMT, fnName, 1, error) < 0) + if (dpiGen__startPublicFn(stmt, DPI_HTYPE_STMT, fnName, error) < 0) return DPI_FAILURE; - if (!stmt->handle) + if (!stmt->handle || (stmt->parentStmt && !stmt->parentStmt->handle)) return dpiError__set(error, "check closed", DPI_ERR_STMT_CLOSED); if (dpiConn__checkConnected(stmt->conn, error) < 0) return DPI_FAILURE; @@ -321,14 +321,19 @@ int dpiStmt__close(dpiStmt *stmt, const char *tag, uint32_t tagLength, dpiStmt__clearBatchErrors(stmt); dpiStmt__clearBindVars(stmt, error); dpiStmt__clearQueryVars(stmt, error); + if (stmt->lastRowid) + dpiGen__setRefCount(stmt->lastRowid, error, -1); if (stmt->handle) { - if (!stmt->conn->deadSession && stmt->conn->handle) { + if (stmt->parentStmt) { + dpiGen__setRefCount(stmt->parentStmt, error, -1); + stmt->parentStmt = NULL; + } else if (!stmt->conn->deadSession && stmt->conn->handle) { if (stmt->isOwned) dpiOci__handleFree(stmt->handle, DPI_OCI_HTYPE_STMT); else status = dpiOci__stmtRelease(stmt, tag, tagLength, propagateErrors, error); } - if (!stmt->conn->closing) + if (!stmt->conn->closing && !stmt->parentStmt) dpiHandleList__removeHandle(stmt->conn->openStmts, stmt->openSlotNum); stmt->handle = NULL; @@ -479,6 +484,7 @@ static int dpiStmt__define(dpiStmt *stmt, uint32_t pos, dpiVar *var, { void *defineHandle = NULL; dpiQueryInfo *queryInfo; + int tempBool; // no need to perform define if variable is unchanged if (stmt->queryVars[pos - 1] == var) @@ -513,6 +519,15 @@ static int dpiStmt__define(dpiStmt *stmt, uint32_t pos, dpiVar *var, return DPI_FAILURE; } + // specify that the LOB length should be prefetched + if (var->nativeTypeNum == DPI_NATIVE_TYPE_LOB) { + tempBool = 1; + if (dpiOci__attrSet(defineHandle, DPI_OCI_HTYPE_DEFINE, + (void*) &tempBool, 0, DPI_OCI_ATTR_LOBPREFETCH_LENGTH, + "set lob prefetch length", error) < 0) + return DPI_FAILURE; + } + // define objects, if applicable if (var->buffer.objectIndicator && dpiOci__defineObject(var, defineHandle, error) < 0) @@ -677,6 +692,10 @@ static int dpiStmt__fetch(dpiStmt *stmt, dpiError *error) void dpiStmt__free(dpiStmt *stmt, dpiError *error) { dpiStmt__close(stmt, NULL, 0, 0, error); + if (stmt->parentStmt) { + dpiGen__setRefCount(stmt->parentStmt, error, -1); + stmt->parentStmt = NULL; + } if (stmt->conn) { dpiGen__setRefCount(stmt->conn, error, -1); stmt->conn = NULL; @@ -753,7 +772,7 @@ static int dpiStmt__getBatchErrors(dpiStmt *stmt, dpiError *error) // get error message localError.buffer = &stmt->batchErrors[i]; localError.handle = batchErrorHandle; - dpiError__check(&localError, DPI_OCI_ERROR, stmt->conn, + dpiError__setFromOCI(&localError, DPI_OCI_ERROR, stmt->conn, "get batch error"); if (error->buffer->errorNum) { overallStatus = DPI_FAILURE; @@ -773,6 +792,42 @@ static int dpiStmt__getBatchErrors(dpiStmt *stmt, dpiError *error) } +//----------------------------------------------------------------------------- +// dpiStmt__getRowCount() [INTERNAL] +// Return the number of rows affected by the last DML executed (for insert, +// update, delete and merge) or the number of rows fetched (for queries). In +// all other cases, 0 is returned. +//----------------------------------------------------------------------------- +static int dpiStmt__getRowCount(dpiStmt *stmt, uint64_t *count, + dpiError *error) +{ + uint32_t rowCount32; + + if (stmt->statementType == DPI_STMT_TYPE_SELECT) + *count = stmt->rowCount; + else if (stmt->statementType != DPI_STMT_TYPE_INSERT && + stmt->statementType != DPI_STMT_TYPE_UPDATE && + stmt->statementType != DPI_STMT_TYPE_DELETE && + stmt->statementType != DPI_STMT_TYPE_MERGE && + stmt->statementType != DPI_STMT_TYPE_CALL && + stmt->statementType != DPI_STMT_TYPE_BEGIN && + stmt->statementType != DPI_STMT_TYPE_DECLARE) { + *count = 0; + } else if (stmt->env->versionInfo->versionNum < 12) { + if (dpiOci__attrGet(stmt->handle, DPI_OCI_HTYPE_STMT, &rowCount32, 0, + DPI_OCI_ATTR_ROW_COUNT, "get row count", error) < 0) + return DPI_FAILURE; + *count = rowCount32; + } else { + if (dpiOci__attrGet(stmt->handle, DPI_OCI_HTYPE_STMT, count, 0, + DPI_OCI_ATTR_UB8_ROW_COUNT, "get row count", error) < 0) + return DPI_FAILURE; + } + + return DPI_SUCCESS; +} + + //----------------------------------------------------------------------------- // dpiStmt__getQueryInfo() [INTERNAL] // Get query information for the position in question. @@ -1484,6 +1539,8 @@ int dpiStmt_getImplicitResult(dpiStmt *stmt, dpiStmt **implicitResult) if (dpiStmt__allocate(stmt->conn, 0, &tempStmt, &error) < 0) return dpiGen__endPublicFn(stmt, DPI_FAILURE, &error); tempStmt->handle = handle; + dpiGen__setRefCount(stmt, &error, 1); + tempStmt->parentStmt = stmt; if (dpiStmt__createQueryVars(tempStmt, &error) < 0) { dpiStmt__free(tempStmt, &error); return dpiGen__endPublicFn(stmt, DPI_FAILURE, &error); @@ -1522,6 +1579,46 @@ int dpiStmt_getInfo(dpiStmt *stmt, dpiStmtInfo *info) } +//----------------------------------------------------------------------------- +// dpiStmt_getLastRowid() [PUBLIC] +// Returns the rowid of the last row that was affected by a DML statement. If +// no rows were affected by the last statement executed or the last statement +// executed was not a DML statement, NULL is returned. +//----------------------------------------------------------------------------- +int dpiStmt_getLastRowid(dpiStmt *stmt, dpiRowid **rowid) +{ + uint64_t rowCount; + dpiError error; + + if (dpiStmt__check(stmt, __func__, &error) < 0) + return dpiGen__endPublicFn(stmt, DPI_FAILURE, &error); + DPI_CHECK_PTR_NOT_NULL(stmt, rowid) + *rowid = NULL; + if (stmt->statementType == DPI_STMT_TYPE_INSERT || + stmt->statementType == DPI_STMT_TYPE_UPDATE || + stmt->statementType == DPI_STMT_TYPE_DELETE || + stmt->statementType == DPI_STMT_TYPE_MERGE) { + if (dpiStmt__getRowCount(stmt, &rowCount, &error) < 0) + return dpiGen__endPublicFn(stmt, DPI_FAILURE, &error); + if (rowCount > 0) { + if (stmt->lastRowid) { + dpiGen__setRefCount(stmt->lastRowid, &error, -1); + stmt->lastRowid = NULL; + } + if (dpiRowid__allocate(stmt->conn, &stmt->lastRowid, &error) < 0) + return dpiGen__endPublicFn(stmt, DPI_FAILURE, &error); + if (dpiOci__attrGet(stmt->handle, DPI_OCI_HTYPE_STMT, + stmt->lastRowid->handle, 0, DPI_OCI_ATTR_ROWID, + "get last rowid", &error) < 0) + return dpiGen__endPublicFn(stmt, DPI_FAILURE, &error); + *rowid = stmt->lastRowid; + } + } + + return dpiGen__endPublicFn(stmt, DPI_SUCCESS, &error); +} + + //----------------------------------------------------------------------------- // dpiStmt_getNumQueryColumns() [PUBLIC] // Returns the number of query columns associated with a statement. If the @@ -1612,33 +1709,14 @@ int dpiStmt_getQueryValue(dpiStmt *stmt, uint32_t pos, //----------------------------------------------------------------------------- int dpiStmt_getRowCount(dpiStmt *stmt, uint64_t *count) { - uint32_t rowCount32; dpiError error; + int status; if (dpiStmt__check(stmt, __func__, &error) < 0) return dpiGen__endPublicFn(stmt, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(stmt, count) - if (stmt->statementType == DPI_STMT_TYPE_SELECT) - *count = stmt->rowCount; - else if (stmt->statementType != DPI_STMT_TYPE_INSERT && - stmt->statementType != DPI_STMT_TYPE_UPDATE && - stmt->statementType != DPI_STMT_TYPE_DELETE && - stmt->statementType != DPI_STMT_TYPE_MERGE && - stmt->statementType != DPI_STMT_TYPE_CALL && - stmt->statementType != DPI_STMT_TYPE_BEGIN && - stmt->statementType != DPI_STMT_TYPE_DECLARE) { - *count = 0; - } else if (stmt->env->versionInfo->versionNum < 12) { - if (dpiOci__attrGet(stmt->handle, DPI_OCI_HTYPE_STMT, &rowCount32, 0, - DPI_OCI_ATTR_ROW_COUNT, "get row count", &error) < 0) - return dpiGen__endPublicFn(stmt, DPI_FAILURE, &error); - *count = rowCount32; - } else { - if (dpiOci__attrGet(stmt->handle, DPI_OCI_HTYPE_STMT, count, 0, - DPI_OCI_ATTR_UB8_ROW_COUNT, "get row count", &error) < 0) - return dpiGen__endPublicFn(stmt, DPI_FAILURE, &error); - } - return dpiGen__endPublicFn(stmt, DPI_SUCCESS, &error); + status = dpiStmt__getRowCount(stmt, count, &error); + return dpiGen__endPublicFn(stmt, status, &error); } @@ -1818,4 +1896,3 @@ int dpiStmt_setFetchArraySize(dpiStmt *stmt, uint32_t arraySize) stmt->fetchArraySize = arraySize; return dpiGen__endPublicFn(stmt, DPI_SUCCESS, &error); } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiSubscr.c b/vendor/github.com/godror/godror/odpi/src/dpiSubscr.c similarity index 93% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiSubscr.c rename to vendor/github.com/godror/godror/odpi/src/dpiSubscr.c index 55c00168e0d..cf1ed60b2d8 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiSubscr.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiSubscr.c @@ -40,9 +40,19 @@ static void dpiSubscr__callback(dpiSubscr *subscr, UNUSED void *handle, dpiError error; // ensure that the subscription handle is still valid - if (dpiGen__startPublicFn(subscr, DPI_HTYPE_SUBSCR, __func__, 1, - &error) < 0) + if (dpiGen__startPublicFn(subscr, DPI_HTYPE_SUBSCR, __func__, + &error) < 0) { dpiGen__endPublicFn(subscr, DPI_FAILURE, &error); + return; + } + + // if the subscription is no longer registered, nothing further to do + dpiMutex__acquire(subscr->mutex); + if (!subscr->registered) { + dpiMutex__release(subscr->mutex); + dpiGen__endPublicFn(subscr, DPI_SUCCESS, &error); + return; + } // populate message memset(&message, 0, sizeof(message)); @@ -52,11 +62,13 @@ static void dpiSubscr__callback(dpiSubscr *subscr, UNUSED void *handle, } message.registered = subscr->registered; - // invoke user callback + // invoke user callback; temporarily increase reference count to ensure + // that the subscription is not freed during the callback + dpiGen__setRefCount(subscr, &error, 1); (*subscr->callback)(subscr->callbackContext, &message); - - // clean up message dpiSubscr__freeMessage(&message); + dpiMutex__release(subscr->mutex); + dpiGen__setRefCount(subscr, &error, -1); dpiGen__endPublicFn(subscr, DPI_SUCCESS, &error); } @@ -68,7 +80,7 @@ static void dpiSubscr__callback(dpiSubscr *subscr, UNUSED void *handle, static int dpiSubscr__check(dpiSubscr *subscr, const char *fnName, dpiError *error) { - if (dpiGen__startPublicFn(subscr, DPI_HTYPE_SUBSCR, fnName, 1, error) < 0) + if (dpiGen__startPublicFn(subscr, DPI_HTYPE_SUBSCR, fnName, error) < 0) return DPI_FAILURE; if (!subscr->handle) return dpiError__set(error, "check closed", DPI_ERR_SUBSCR_CLOSED); @@ -84,7 +96,7 @@ static int dpiSubscr__check(dpiSubscr *subscr, const char *fnName, int dpiSubscr__create(dpiSubscr *subscr, dpiConn *conn, dpiSubscrCreateParams *params, dpiError *error) { - uint32_t qosFlags; + uint32_t qosFlags, mode; int32_t int32Val; int rowids; @@ -95,6 +107,8 @@ int dpiSubscr__create(dpiSubscr *subscr, dpiConn *conn, subscr->callbackContext = params->callbackContext; subscr->subscrNamespace = params->subscrNamespace; subscr->qos = params->qos; + subscr->clientInitiated = params->clientInitiated; + dpiMutex__initialize(subscr->mutex); // create the subscription handle if (dpiOci__handleAlloc(conn->env->handle, &subscr->handle, @@ -222,11 +236,27 @@ int dpiSubscr__create(dpiSubscr *subscr, dpiConn *conn, } - // register the subscription - if (dpiOci__subscriptionRegister(conn, &subscr->handle, error) < 0) + // register the subscription; client initiated subscriptions are only valid + // with 19.4 client and database + mode = DPI_OCI_DEFAULT; + if (params->clientInitiated) { + if (dpiUtils__checkClientVersion(conn->env->versionInfo, 19, 4, + error) < 0) + return DPI_FAILURE; + if (dpiUtils__checkDatabaseVersion(conn, 19, 4, error) < 0) + return DPI_FAILURE; + mode = DPI_OCI_SECURE_NOTIFICATION; + } + if (dpiOci__subscriptionRegister(conn, &subscr->handle, mode, error) < 0) return DPI_FAILURE; subscr->registered = 1; + // acquire the registration id + if (dpiOci__attrGet(subscr->handle, DPI_OCI_HTYPE_SUBSCRIPTION, + ¶ms->outRegId, NULL, DPI_OCI_ATTR_SUBSCR_CQ_REGID, + "get registration id", error) < 0) + return DPI_FAILURE; + return DPI_SUCCESS; } @@ -237,6 +267,7 @@ int dpiSubscr__create(dpiSubscr *subscr, dpiConn *conn, //----------------------------------------------------------------------------- void dpiSubscr__free(dpiSubscr *subscr, dpiError *error) { + dpiMutex__acquire(subscr->mutex); if (subscr->handle) { if (subscr->registered) dpiOci__subscriptionUnRegister(subscr->conn, subscr, error); @@ -247,6 +278,8 @@ void dpiSubscr__free(dpiSubscr *subscr, dpiError *error) dpiGen__setRefCount(subscr->conn, error, -1); subscr->conn = NULL; } + dpiMutex__release(subscr->mutex); + dpiMutex__destroy(subscr->mutex); dpiUtils__freeMemory(subscr); } @@ -615,9 +648,12 @@ static int dpiSubscr__populateQueryChangeMessage(dpiSubscr *subscr, static int dpiSubscr__prepareStmt(dpiSubscr *subscr, dpiStmt *stmt, const char *sql, uint32_t sqlLength, dpiError *error) { - // prepare statement for execution + // prepare statement for execution; only SELECT statements are supported if (dpiStmt__prepare(stmt, sql, sqlLength, NULL, 0, error) < 0) return DPI_FAILURE; + if (stmt->statementType != DPI_STMT_TYPE_SELECT) + return dpiError__set(error, "subscr prepare statement", + DPI_ERR_NOT_SUPPORTED); // fetch array size is set to 1 in order to avoid over allocation since // the query is not really going to be used for fetching rows, just for @@ -675,4 +711,3 @@ int dpiSubscr_release(dpiSubscr *subscr) { return dpiGen__release(subscr, DPI_HTYPE_SUBSCR, __func__); } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiUtils.c b/vendor/github.com/godror/godror/odpi/src/dpiUtils.c similarity index 99% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiUtils.c rename to vendor/github.com/godror/godror/odpi/src/dpiUtils.c index 1aad9118400..0ab09e54487 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiUtils.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiUtils.c @@ -251,7 +251,7 @@ int dpiUtils__parseNumberString(const char *value, uint32_t valueLength, return dpiError__set(error, "no digits in exponent", DPI_ERR_INVALID_NUMBER); exponentDigits[numExponentDigits] = '\0'; - exponent = (int16_t) strtol(exponentDigits, NULL, 0); + exponent = (int16_t) strtol(exponentDigits, NULL, 10); if (exponentIsNegative) exponent = -exponent; *decimalPointIndex += exponent; @@ -399,4 +399,3 @@ int dpiUtils__setAttributesFromCommonCreateParams(void *handle, return DPI_SUCCESS; } - diff --git a/vendor/gopkg.in/goracle.v2/odpi/src/dpiVar.c b/vendor/github.com/godror/godror/odpi/src/dpiVar.c similarity index 97% rename from vendor/gopkg.in/goracle.v2/odpi/src/dpiVar.c rename to vendor/github.com/godror/godror/odpi/src/dpiVar.c index de9db59bc48..d8cde787c64 100644 --- a/vendor/gopkg.in/goracle.v2/odpi/src/dpiVar.c +++ b/vendor/github.com/godror/godror/odpi/src/dpiVar.c @@ -226,10 +226,9 @@ static void dpiVar__assignCallbackBuffer(dpiVar *var, dpiVarBuffer *buffer, // Verifies that the array size has not been exceeded. //----------------------------------------------------------------------------- static int dpiVar__checkArraySize(dpiVar *var, uint32_t pos, - const char *fnName, int needErrorHandle, dpiError *error) + const char *fnName, dpiError *error) { - if (dpiGen__startPublicFn(var, DPI_HTYPE_VAR, fnName, needErrorHandle, - error) < 0) + if (dpiGen__startPublicFn(var, DPI_HTYPE_VAR, fnName, error) < 0) return DPI_FAILURE; if (pos >= var->buffer.maxArraySize) return dpiError__set(error, "check array size", @@ -629,7 +628,6 @@ int dpiVar__getValue(dpiVar *var, dpiVarBuffer *buffer, uint32_t pos, return DPI_SUCCESS; } - // check for a NULL value; for objects the indicator is elsewhere data = &buffer->externalData[pos]; if (!buffer->objectIndicator) @@ -638,8 +636,17 @@ int dpiVar__getValue(dpiVar *var, dpiVarBuffer *buffer, uint32_t pos, data->isNull = (*((int16_t*) buffer->objectIndicator[pos]) == DPI_OCI_IND_NULL); else data->isNull = 1; - if (data->isNull) + if (data->isNull) { + if (inFetch && var->objectType && var->objectType->isCollection) { + if (dpiOci__objectFree(var->env->handle, + buffer->data.asObject[pos], 1, error) < 0) + return DPI_FAILURE; + if (dpiOci__objectFree(var->env->handle, + buffer->objectIndicator[pos], 1, error) < 0) + return DPI_FAILURE; + } return DPI_SUCCESS; + } // check return code for variable length data if (buffer->returnCode) { @@ -781,8 +788,8 @@ int dpiVar__getValue(dpiVar *var, dpiVarBuffer *buffer, uint32_t pos, // does nothing useful except satisfy OCI requirements. //----------------------------------------------------------------------------- int32_t dpiVar__inBindCallback(dpiVar *var, UNUSED void *bindp, - UNUSED uint32_t iter, uint32_t index, void **bufpp, uint32_t *alenp, - uint8_t *piecep, void **indpp) + UNUSED uint32_t iter, UNUSED uint32_t index, void **bufpp, + uint32_t *alenp, uint8_t *piecep, void **indpp) { dpiDynamicBytes *dynBytes; @@ -1208,7 +1215,8 @@ static int dpiVar__setFromBytes(dpiVar *var, uint32_t pos, const char *value, dynBytes = &var->buffer.dynamicBytes[pos]; if (dpiVar__allocateDynamicBytes(dynBytes, valueLength, error) < 0) return DPI_FAILURE; - memcpy(dynBytes->chunks->ptr, value, valueLength); + if (valueLength > 0) + memcpy(dynBytes->chunks->ptr, value, valueLength); dynBytes->numChunks = 1; dynBytes->chunks->length = valueLength; bytes->ptr = dynBytes->chunks->ptr; @@ -1461,6 +1469,10 @@ int dpiVar__setValue(dpiVar *var, dpiVarBuffer *buffer, uint32_t pos, case DPI_ORACLE_TYPE_NUMBER: return dpiDataBuffer__toOracleNumberFromDouble( &data->value, error, &buffer->data.asNumber[pos]); + case DPI_ORACLE_TYPE_DATE: + return dpiDataBuffer__toOracleDateFromDouble( + &data->value, var->env, error, + &buffer->data.asDate[pos]); case DPI_ORACLE_TYPE_TIMESTAMP: case DPI_ORACLE_TYPE_TIMESTAMP_TZ: case DPI_ORACLE_TYPE_TIMESTAMP_LTZ: @@ -1520,6 +1532,7 @@ static int dpiVar__validateTypes(const dpiOracleType *oracleType, dpiNativeTypeNum nativeTypeNum, dpiError *error) { switch (oracleType->oracleTypeNum) { + case DPI_ORACLE_TYPE_DATE: case DPI_ORACLE_TYPE_TIMESTAMP: case DPI_ORACLE_TYPE_TIMESTAMP_TZ: case DPI_ORACLE_TYPE_TIMESTAMP_LTZ: @@ -1564,7 +1577,7 @@ int dpiVar_copyData(dpiVar *var, uint32_t pos, dpiVar *sourceVar, dpiError error; int status; - if (dpiVar__checkArraySize(var, pos, __func__, 1, &error) < 0) + if (dpiVar__checkArraySize(var, pos, __func__, &error) < 0) return dpiGen__endPublicFn(var, DPI_FAILURE, &error); if (dpiGen__checkHandle(sourceVar, DPI_HTYPE_VAR, "check source var", &error) < 0) @@ -1594,7 +1607,7 @@ int dpiVar_getNumElementsInArray(dpiVar *var, uint32_t *numElements) { dpiError error; - if (dpiGen__startPublicFn(var, DPI_HTYPE_VAR, __func__, 0, &error) < 0) + if (dpiGen__startPublicFn(var, DPI_HTYPE_VAR, __func__, &error) < 0) return dpiGen__endPublicFn(var, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(var, numElements) if (var->dynBindBuffers) @@ -1618,7 +1631,7 @@ int dpiVar_getReturnedData(dpiVar *var, uint32_t pos, uint32_t *numElements, { dpiError error; - if (dpiVar__checkArraySize(var, pos, __func__, 1, &error) < 0) + if (dpiVar__checkArraySize(var, pos, __func__, &error) < 0) return dpiGen__endPublicFn(var, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(var, numElements) DPI_CHECK_PTR_NOT_NULL(var, data) @@ -1642,7 +1655,7 @@ int dpiVar_getSizeInBytes(dpiVar *var, uint32_t *sizeInBytes) { dpiError error; - if (dpiGen__startPublicFn(var, DPI_HTYPE_VAR, __func__, 0, &error) < 0) + if (dpiGen__startPublicFn(var, DPI_HTYPE_VAR, __func__, &error) < 0) return dpiGen__endPublicFn(var, DPI_FAILURE, &error); DPI_CHECK_PTR_NOT_NULL(var, sizeInBytes) *sizeInBytes = var->sizeInBytes; @@ -1673,9 +1686,9 @@ int dpiVar_setFromBytes(dpiVar *var, uint32_t pos, const char *value, dpiError error; int status; - if (dpiVar__checkArraySize(var, pos, __func__, 1, &error) < 0) + if (dpiVar__checkArraySize(var, pos, __func__, &error) < 0) return dpiGen__endPublicFn(var, DPI_FAILURE, &error); - DPI_CHECK_PTR_NOT_NULL(var, value) + DPI_CHECK_PTR_AND_LENGTH(var, value) if (var->nativeTypeNum != DPI_NATIVE_TYPE_BYTES && var->nativeTypeNum != DPI_NATIVE_TYPE_LOB) { dpiError__set(&error, "native type", DPI_ERR_NOT_SUPPORTED); @@ -1702,7 +1715,7 @@ int dpiVar_setFromLob(dpiVar *var, uint32_t pos, dpiLob *lob) dpiError error; int status; - if (dpiVar__checkArraySize(var, pos, __func__, 1, &error) < 0) + if (dpiVar__checkArraySize(var, pos, __func__, &error) < 0) return dpiGen__endPublicFn(var, DPI_FAILURE, &error); if (var->nativeTypeNum != DPI_NATIVE_TYPE_LOB) { dpiError__set(&error, "native type", DPI_ERR_NOT_SUPPORTED); @@ -1724,7 +1737,7 @@ int dpiVar_setFromObject(dpiVar *var, uint32_t pos, dpiObject *obj) dpiError error; int status; - if (dpiVar__checkArraySize(var, pos, __func__, 1, &error) < 0) + if (dpiVar__checkArraySize(var, pos, __func__, &error) < 0) return dpiGen__endPublicFn(var, DPI_FAILURE, &error); if (var->nativeTypeNum != DPI_NATIVE_TYPE_OBJECT) { dpiError__set(&error, "native type", DPI_ERR_NOT_SUPPORTED); @@ -1746,7 +1759,7 @@ int dpiVar_setFromRowid(dpiVar *var, uint32_t pos, dpiRowid *rowid) dpiError error; int status; - if (dpiVar__checkArraySize(var, pos, __func__, 1, &error) < 0) + if (dpiVar__checkArraySize(var, pos, __func__, &error) < 0) return dpiGen__endPublicFn(var, DPI_FAILURE, &error); if (var->nativeTypeNum != DPI_NATIVE_TYPE_ROWID) { dpiError__set(&error, "native type", DPI_ERR_NOT_SUPPORTED); @@ -1768,7 +1781,7 @@ int dpiVar_setFromStmt(dpiVar *var, uint32_t pos, dpiStmt *stmt) dpiError error; int status; - if (dpiVar__checkArraySize(var, pos, __func__, 1, &error) < 0) + if (dpiVar__checkArraySize(var, pos, __func__, &error) < 0) return dpiGen__endPublicFn(var, DPI_FAILURE, &error); if (var->nativeTypeNum != DPI_NATIVE_TYPE_STMT) { dpiError__set(&error, "native type", DPI_ERR_NOT_SUPPORTED); @@ -1788,7 +1801,7 @@ int dpiVar_setNumElementsInArray(dpiVar *var, uint32_t numElements) { dpiError error; - if (dpiGen__startPublicFn(var, DPI_HTYPE_VAR, __func__, 0, &error) < 0) + if (dpiGen__startPublicFn(var, DPI_HTYPE_VAR, __func__, &error) < 0) return dpiGen__endPublicFn(var, DPI_FAILURE, &error); if (numElements > var->buffer.maxArraySize) { dpiError__set(&error, "check num elements", @@ -1798,4 +1811,3 @@ int dpiVar_setNumElementsInArray(dpiVar *var, uint32_t numElements) var->buffer.actualArraySize = numElements; return dpiGen__endPublicFn(var, DPI_SUCCESS, &error); } - diff --git a/vendor/gopkg.in/goracle.v2/orahlp.go b/vendor/github.com/godror/godror/orahlp.go similarity index 55% rename from vendor/gopkg.in/goracle.v2/orahlp.go rename to vendor/github.com/godror/godror/orahlp.go index 6775a4678da..b9b5068f51f 100644 --- a/vendor/gopkg.in/goracle.v2/orahlp.go +++ b/vendor/github.com/godror/godror/orahlp.go @@ -1,19 +1,9 @@ // Copyright 2017 Tamás Gulácsi // // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-License-Identifier: UPL-1.0 OR Apache-2.0 -package goracle +package godror import ( "bufio" @@ -23,11 +13,211 @@ import ( "database/sql/driver" "fmt" "io" + "math" + "strconv" "sync" + "time" - "github.com/pkg/errors" + errors "golang.org/x/xerrors" ) +// Number as string +type Number string + +var ( + // Int64 for converting to-from int64. + Int64 = intType{} + // Float64 for converting to-from float64. + Float64 = floatType{} + // Num for converting to-from Number (string) + Num = numType{} +) + +type intType struct{} + +func (intType) String() string { return "Int64" } +func (intType) ConvertValue(v interface{}) (driver.Value, error) { + if Log != nil { + Log("ConvertValue", "Int64", "value", v) + } + switch x := v.(type) { + case int8: + return int64(x), nil + case int16: + return int64(x), nil + case int32: + return int64(x), nil + case int64: + return x, nil + case uint16: + return int64(x), nil + case uint32: + return int64(x), nil + case uint64: + return int64(x), nil + case float32: + if _, f := math.Modf(float64(x)); f != 0 { + return int64(x), errors.Errorf("non-zero fractional part: %f", f) + } + return int64(x), nil + case float64: + if _, f := math.Modf(x); f != 0 { + return int64(x), errors.Errorf("non-zero fractional part: %f", f) + } + return int64(x), nil + case string: + if x == "" { + return 0, nil + } + return strconv.ParseInt(x, 10, 64) + case Number: + if x == "" { + return 0, nil + } + return strconv.ParseInt(string(x), 10, 64) + default: + return nil, errors.Errorf("unknown type %T", v) + } +} + +type floatType struct{} + +func (floatType) String() string { return "Float64" } +func (floatType) ConvertValue(v interface{}) (driver.Value, error) { + if Log != nil { + Log("ConvertValue", "Float64", "value", v) + } + switch x := v.(type) { + case int8: + return float64(x), nil + case int16: + return float64(x), nil + case int32: + return float64(x), nil + case uint16: + return float64(x), nil + case uint32: + return float64(x), nil + case int64: + return float64(x), nil + case uint64: + return float64(x), nil + case float32: + return float64(x), nil + case float64: + return x, nil + case string: + if x == "" { + return 0, nil + } + return strconv.ParseFloat(x, 64) + case Number: + if x == "" { + return 0, nil + } + return strconv.ParseFloat(string(x), 64) + default: + return nil, errors.Errorf("unknown type %T", v) + } +} + +type numType struct{} + +func (numType) String() string { return "Num" } +func (numType) ConvertValue(v interface{}) (driver.Value, error) { + if Log != nil { + Log("ConvertValue", "Num", "value", v) + } + switch x := v.(type) { + case string: + if x == "" { + return 0, nil + } + return x, nil + case Number: + if x == "" { + return 0, nil + } + return string(x), nil + case int8, int16, int32, int64, uint16, uint32, uint64: + return fmt.Sprintf("%d", x), nil + case float32, float64: + return fmt.Sprintf("%f", x), nil + default: + return nil, errors.Errorf("unknown type %T", v) + } +} +func (n Number) String() string { return string(n) } + +// Value returns the Number as driver.Value +func (n Number) Value() (driver.Value, error) { + return string(n), nil +} + +// Scan into the Number from a driver.Value. +func (n *Number) Scan(v interface{}) error { + if v == nil { + *n = "" + return nil + } + switch x := v.(type) { + case string: + *n = Number(x) + case Number: + *n = x + case int8, int16, int32, int64, uint16, uint32, uint64: + *n = Number(fmt.Sprintf("%d", x)) + case float32, float64: + *n = Number(fmt.Sprintf("%f", x)) + default: + return errors.Errorf("unknown type %T", v) + } + return nil +} + +// MarshalText marshals a Number to text. +func (n Number) MarshalText() ([]byte, error) { return []byte(n), nil } + +// UnmarshalText parses text into a Number. +func (n *Number) UnmarshalText(p []byte) error { + var dotNum int + for i, c := range p { + if !(c == '-' && i == 0 || '0' <= c && c <= '9') { + if c == '.' { + dotNum++ + if dotNum == 1 { + continue + } + } + return errors.Errorf("unknown char %c in %q", c, p) + } + } + *n = Number(p) + return nil +} + +// MarshalJSON marshals a Number into a JSON string. +func (n Number) MarshalJSON() ([]byte, error) { + b, err := n.MarshalText() + b2 := make([]byte, 1, 1+len(b)+1) + b2[0] = '"' + b2 = append(b2, b...) + b2 = append(b2, '"') + return b2, err +} + +// UnmarshalJSON parses a JSON string into the Number. +func (n *Number) UnmarshalJSON(p []byte) error { + *n = Number("") + if len(p) == 0 { + return nil + } + if len(p) > 2 && p[0] == '"' && p[len(p)-1] == '"' { + p = p[1 : len(p)-1] + } + return n.UnmarshalText(p) +} + // QueryColumn is the described column. type QueryColumn struct { Name string @@ -52,10 +242,11 @@ type Querier interface { // This can help using unknown-at-compile-time, a.k.a. // dynamic queries. func DescribeQuery(ctx context.Context, db Execer, qry string) ([]QueryColumn, error) { - c, err := getConn(db) + c, err := getConn(ctx, db) if err != nil { return nil, err } + defer c.close(false) stmt, err := c.PrepareContext(ctx, qry) if err != nil { @@ -213,7 +404,10 @@ func MapToSlice(qry string, metParam func(string) interface{}) (string, []interf func EnableDbmsOutput(ctx context.Context, conn Execer) error { qry := "BEGIN DBMS_OUTPUT.enable(1000000); END;" _, err := conn.ExecContext(ctx, qry) - return errors.Wrap(err, qry) + if err != nil { + return errors.Errorf("%s: %w", qry, err) + } + return nil } // ReadDbmsOutput copies the DBMS_OUTPUT buffer into the given io.Writer. @@ -224,7 +418,7 @@ func ReadDbmsOutput(ctx context.Context, w io.Writer, conn preparer) error { const qry = `BEGIN DBMS_OUTPUT.get_lines(:1, :2); END;` stmt, err := conn.PrepareContext(ctx, qry) if err != nil { - return errors.Wrap(err, qry) + return errors.Errorf("%s: %w", qry, err) } lines := make([]string, maxNumLines) @@ -237,7 +431,7 @@ func ReadDbmsOutput(ctx context.Context, w io.Writer, conn preparer) error { numLines = int64(len(lines)) if _, err = stmt.ExecContext(ctx, params...); err != nil { _ = bw.Flush() - return errors.Wrap(err, qry) + return errors.Errorf("%s: %w", qry, err) } for i := 0; i < int(numLines); i++ { _, _ = bw.WriteString(lines[i]) @@ -253,8 +447,8 @@ func ReadDbmsOutput(ctx context.Context, w io.Writer, conn preparer) error { } // ClientVersion returns the VersionInfo from the DB. -func ClientVersion(ex Execer) (VersionInfo, error) { - c, err := getConn(ex) +func ClientVersion(ctx context.Context, ex Execer) (VersionInfo, error) { + c, err := getConn(ctx, ex) if err != nil { return VersionInfo{}, err } @@ -262,8 +456,8 @@ func ClientVersion(ex Execer) (VersionInfo, error) { } // ServerVersion returns the VersionInfo of the client. -func ServerVersion(ex Execer) (VersionInfo, error) { - c, err := getConn(ex) +func ServerVersion(ctx context.Context, ex Execer) (VersionInfo, error) { + c, err := getConn(ctx, ex) if err != nil { return VersionInfo{}, err } @@ -273,32 +467,37 @@ func ServerVersion(ex Execer) (VersionInfo, error) { // Conn is the interface for a connection, to be returned by DriverConn. type Conn interface { driver.Conn + driver.ConnBeginTx + driver.ConnPrepareContext driver.Pinger + Break() error - BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) - PrepareContext(ctx context.Context, query string) (driver.Stmt, error) Commit() error Rollback() error + ClientVersion() (VersionInfo, error) ServerVersion() (VersionInfo, error) GetObjectType(name string) (ObjectType, error) NewSubscription(string, func(Event)) (*Subscription, error) Startup(StartupMode) error Shutdown(ShutdownMode) error + NewData(baseType interface{}, SliceLen, BufSize int) ([]*Data, error) + + Timezone() *time.Location } -// DriverConn returns the *goracle.conn of the database/sql.Conn -func DriverConn(ex Execer) (Conn, error) { - return getConn(ex) +// DriverConn returns the *godror.conn of the database/sql.Conn +func DriverConn(ctx context.Context, ex Execer) (Conn, error) { + return getConn(ctx, ex) } var getConnMu sync.Mutex -func getConn(ex Execer) (*conn, error) { +func getConn(ctx context.Context, ex Execer) (*conn, error) { getConnMu.Lock() defer getConnMu.Unlock() var c interface{} - if _, err := ex.ExecContext(context.Background(), getConnection, sql.Out{Dest: &c}); err != nil { - return nil, errors.Wrap(err, "getConnection") + if _, err := ex.ExecContext(ctx, getConnection, sql.Out{Dest: &c}); err != nil { + return nil, errors.Errorf("getConnection: %w", err) } return c.(*conn), nil } @@ -307,3 +506,11 @@ func getConn(ex Execer) (*conn, error) { func WrapRows(ctx context.Context, q Querier, rset driver.Rows) (*sql.Rows, error) { return q.QueryContext(ctx, wrapResultset, rset) } + +func Timezone(ctx context.Context, ex Execer) (*time.Location, error) { + c, err := getConn(ctx, ex) + if err != nil { + return nil, err + } + return c.Timezone(), nil +} diff --git a/vendor/github.com/godror/godror/queue.go b/vendor/github.com/godror/godror/queue.go new file mode 100644 index 00000000000..70b4d018377 --- /dev/null +++ b/vendor/github.com/godror/godror/queue.go @@ -0,0 +1,639 @@ +// Copyright 2019 Tamás Gulácsi +// +// +// SPDX-License-Identifier: UPL-1.0 OR Apache-2.0 + +package godror + +/* +#include +#include "dpiImpl.h" +*/ +import "C" +import ( + "context" + "sync" + "time" + "unsafe" + + errors "golang.org/x/xerrors" +) + +const MsgIDLength = 16 + +var zeroMsgID [MsgIDLength]byte + +// DefaultEnqOptions is the default set for NewQueue. +var DefaultEnqOptions = EnqOptions{ + Visibility: VisibleImmediate, + DeliveryMode: DeliverPersistent, +} + +// DefaultDeqOptions is the default set for NewQueue. +var DefaultDeqOptions = DeqOptions{ + Mode: DeqRemove, + DeliveryMode: DeliverPersistent, + Navigation: NavFirst, + Visibility: VisibleImmediate, + Wait: 30, +} + +// Queue represents an Oracle Advanced Queue. +type Queue struct { + PayloadObjectType ObjectType + props []*C.dpiMsgProps + name string + conn *conn + dpiQueue *C.dpiQueue + + mu sync.Mutex +} + +// NewQueue creates a new Queue. +// +// WARNING: the connection given to it must not be closed before the Queue is closed! +// So use an sql.Conn for it. +func NewQueue(ctx context.Context, execer Execer, name string, payloadObjectTypeName string) (*Queue, error) { + cx, err := DriverConn(ctx, execer) + if err != nil { + return nil, err + } + Q := Queue{conn: cx.(*conn), name: name} + + var payloadType *C.dpiObjectType + if payloadObjectTypeName != "" { + if Q.PayloadObjectType, err = Q.conn.GetObjectType(payloadObjectTypeName); err != nil { + return nil, err + } else { + payloadType = Q.PayloadObjectType.dpiObjectType + } + } + value := C.CString(name) + if C.dpiConn_newQueue(Q.conn.dpiConn, value, C.uint(len(name)), payloadType, &Q.dpiQueue) == C.DPI_FAILURE { + err = errors.Errorf("newQueue %q: %w", name, Q.conn.drv.getError()) + } + C.free(unsafe.Pointer(value)) + if err != nil { + cx.Close() + return nil, err + } + if err = Q.SetEnqOptions(DefaultEnqOptions); err != nil { + cx.Close() + Q.Close() + return nil, err + } + if err = Q.SetDeqOptions(DefaultDeqOptions); err != nil { + cx.Close() + Q.Close() + return nil, err + } + return &Q, nil +} + +// Close the queue. +func (Q *Queue) Close() error { + c, q := Q.conn, Q.dpiQueue + Q.conn, Q.dpiQueue = nil, nil + if q == nil { + return nil + } + if C.dpiQueue_release(q) == C.DPI_FAILURE { + return errors.Errorf("release: %w", c.getError()) + } + return nil +} + +// Name of the queue. +func (Q *Queue) Name() string { return Q.name } + +// EnqOptions returns the queue's enqueue options in effect. +func (Q *Queue) EnqOptions() (EnqOptions, error) { + var E EnqOptions + var opts *C.dpiEnqOptions + if C.dpiQueue_getEnqOptions(Q.dpiQueue, &opts) == C.DPI_FAILURE { + return E, errors.Errorf("getEnqOptions: %w", Q.conn.drv.getError()) + } + err := E.fromOra(Q.conn.drv, opts) + return E, err +} + +// DeqOptions returns the queue's dequeue options in effect. +func (Q *Queue) DeqOptions() (DeqOptions, error) { + var D DeqOptions + var opts *C.dpiDeqOptions + if C.dpiQueue_getDeqOptions(Q.dpiQueue, &opts) == C.DPI_FAILURE { + return D, errors.Errorf("getDeqOptions: %w", Q.conn.drv.getError()) + } + err := D.fromOra(Q.conn.drv, opts) + return D, err +} + +// Dequeues messages into the given slice. +// Returns the number of messages filled in the given slice. +func (Q *Queue) Dequeue(messages []Message) (int, error) { + Q.mu.Lock() + defer Q.mu.Unlock() + var props []*C.dpiMsgProps + if cap(Q.props) >= len(messages) { + props = Q.props[:len(messages)] + } else { + props = make([]*C.dpiMsgProps, len(messages)) + } + Q.props = props + + var ok C.int + num := C.uint(len(props)) + if num == 1 { + ok = C.dpiQueue_deqOne(Q.dpiQueue, &props[0]) + } else { + ok = C.dpiQueue_deqMany(Q.dpiQueue, &num, &props[0]) + } + if ok == C.DPI_FAILURE { + err := Q.conn.getError() + if code := err.(interface{ Code() int }).Code(); code == 3156 { + return 0, context.DeadlineExceeded + } + return 0, errors.Errorf("dequeue: %w", err) + } + var firstErr error + for i, p := range props[:int(num)] { + if err := messages[i].fromOra(Q.conn, p, &Q.PayloadObjectType); err != nil { + if firstErr == nil { + firstErr = err + } + } + C.dpiMsgProps_release(p) + } + return int(num), firstErr +} + +// Enqueue all the messages given. +// +// WARNING: calling this function in parallel on different connections acquired from the same pool may fail due to Oracle bug 29928074. Ensure that this function is not run in parallel, use standalone connections or connections from different pools, or make multiple calls to Queue.enqOne() instead. The function Queue.Dequeue() call is not affected. +func (Q *Queue) Enqueue(messages []Message) error { + Q.mu.Lock() + defer Q.mu.Unlock() + var props []*C.dpiMsgProps + if cap(Q.props) >= len(messages) { + props = Q.props[:len(messages)] + } else { + props = make([]*C.dpiMsgProps, len(messages)) + } + Q.props = props + defer func() { + for _, p := range props { + if p != nil { + C.dpiMsgProps_release(p) + } + } + }() + for i, m := range messages { + if C.dpiConn_newMsgProps(Q.conn.dpiConn, &props[i]) == C.DPI_FAILURE { + return errors.Errorf("newMsgProps: %w", Q.conn.getError()) + } + if err := m.toOra(Q.conn.drv, props[i]); err != nil { + return err + } + } + + var ok C.int + if len(messages) == 1 { + ok = C.dpiQueue_enqOne(Q.dpiQueue, props[0]) + } else { + ok = C.dpiQueue_enqMany(Q.dpiQueue, C.uint(len(props)), &props[0]) + } + if ok == C.DPI_FAILURE { + return errors.Errorf("enqueue %#v: %w", messages, Q.conn.getError()) + } + + return nil +} + +// Message is a message - either received or being sent. +type Message struct { + Correlation, ExceptionQ string + Enqueued time.Time + MsgID, OriginalMsgID [16]byte + Raw []byte + Delay, Expiration int32 + Priority, NumAttempts int32 + Object *Object + DeliveryMode DeliveryMode + State MessageState +} + +func (M *Message) toOra(d *drv, props *C.dpiMsgProps) error { + var firstErr error + OK := func(ok C.int, name string) { + if ok == C.DPI_SUCCESS { + return + } + if firstErr == nil { + firstErr = errors.Errorf("%s: %w", name, d.getError()) + } + } + if M.Correlation != "" { + value := C.CString(M.Correlation) + OK(C.dpiMsgProps_setCorrelation(props, value, C.uint(len(M.Correlation))), "setCorrelation") + C.free(unsafe.Pointer(value)) + } + + if M.Delay != 0 { + OK(C.dpiMsgProps_setDelay(props, C.int(M.Delay)), "setDelay") + } + + if M.ExceptionQ != "" { + value := C.CString(M.ExceptionQ) + OK(C.dpiMsgProps_setExceptionQ(props, value, C.uint(len(M.ExceptionQ))), "setExceptionQ") + C.free(unsafe.Pointer(value)) + } + + if M.Expiration != 0 { + OK(C.dpiMsgProps_setExpiration(props, C.int(M.Expiration)), "setExpiration") + } + + if M.OriginalMsgID != zeroMsgID { + OK(C.dpiMsgProps_setOriginalMsgId(props, (*C.char)(unsafe.Pointer(&M.OriginalMsgID[0])), MsgIDLength), "setMsgOriginalId") + } + + OK(C.dpiMsgProps_setPriority(props, C.int(M.Priority)), "setPriority") + + if M.Object == nil { + OK(C.dpiMsgProps_setPayloadBytes(props, (*C.char)(unsafe.Pointer(&M.Raw[0])), C.uint(len(M.Raw))), "setPayloadBytes") + } else { + OK(C.dpiMsgProps_setPayloadObject(props, M.Object.dpiObject), "setPayloadObject") + } + + return firstErr +} + +func (M *Message) fromOra(c *conn, props *C.dpiMsgProps, objType *ObjectType) error { + var firstErr error + OK := func(ok C.int, name string) bool { + if ok == C.DPI_SUCCESS { + return true + } + if firstErr == nil { + firstErr = errors.Errorf("%s: %w", name, c.getError()) + } + return false + } + M.NumAttempts = 0 + var cint C.int + if OK(C.dpiMsgProps_getNumAttempts(props, &cint), "getNumAttempts") { + M.NumAttempts = int32(cint) + } + var value *C.char + var length C.uint + M.Correlation = "" + if OK(C.dpiMsgProps_getCorrelation(props, &value, &length), "getCorrelation") { + M.Correlation = C.GoStringN(value, C.int(length)) + } + + M.Delay = 0 + if OK(C.dpiMsgProps_getDelay(props, &cint), "getDelay") { + M.Delay = int32(cint) + } + + M.DeliveryMode = DeliverPersistent + var mode C.dpiMessageDeliveryMode + if OK(C.dpiMsgProps_getDeliveryMode(props, &mode), "getDeliveryMode") { + M.DeliveryMode = DeliveryMode(mode) + } + + M.ExceptionQ = "" + if OK(C.dpiMsgProps_getExceptionQ(props, &value, &length), "getExceptionQ") { + M.ExceptionQ = C.GoStringN(value, C.int(length)) + } + + var ts C.dpiTimestamp + M.Enqueued = time.Time{} + if OK(C.dpiMsgProps_getEnqTime(props, &ts), "getEnqTime") { + tz := c.timeZone + if ts.tzHourOffset != 0 || ts.tzMinuteOffset != 0 { + tz = timeZoneFor(ts.tzHourOffset, ts.tzMinuteOffset) + } + if tz == nil { + tz = time.Local + } + M.Enqueued = time.Date( + int(ts.year), time.Month(ts.month), int(ts.day), + int(ts.hour), int(ts.minute), int(ts.second), int(ts.fsecond), + tz, + ) + } + + M.Expiration = 0 + if OK(C.dpiMsgProps_getExpiration(props, &cint), "getExpiration") { + M.Expiration = int32(cint) + } + + M.MsgID = zeroMsgID + if OK(C.dpiMsgProps_getMsgId(props, &value, &length), "getMsgId") { + n := C.int(length) + if n > MsgIDLength { + n = MsgIDLength + } + copy(M.MsgID[:], C.GoBytes(unsafe.Pointer(value), n)) + } + + M.OriginalMsgID = zeroMsgID + if OK(C.dpiMsgProps_getOriginalMsgId(props, &value, &length), "getMsgOriginalId") { + n := C.int(length) + if n > MsgIDLength { + n = MsgIDLength + } + copy(M.OriginalMsgID[:], C.GoBytes(unsafe.Pointer(value), n)) + } + + M.Priority = 0 + if OK(C.dpiMsgProps_getPriority(props, &cint), "getPriority") { + M.Priority = int32(cint) + } + + M.State = 0 + var state C.dpiMessageState + if OK(C.dpiMsgProps_getState(props, &state), "getState") { + M.State = MessageState(state) + } + + M.Raw = nil + M.Object = nil + var obj *C.dpiObject + if OK(C.dpiMsgProps_getPayload(props, &obj, &value, &length), "getPayload") { + if obj == nil { + M.Raw = C.GoBytes(unsafe.Pointer(value), C.int(length)) + } else { + if C.dpiObject_addRef(obj) == C.DPI_FAILURE { + return objType.getError() + } + M.Object = &Object{dpiObject: obj, ObjectType: *objType} + } + } + return nil +} + +// EnqOptions are the options used to enqueue a message. +type EnqOptions struct { + Transformation string + Visibility Visibility + DeliveryMode DeliveryMode +} + +func (E *EnqOptions) fromOra(d *drv, opts *C.dpiEnqOptions) error { + var firstErr error + OK := func(ok C.int, msg string) bool { + if ok == C.DPI_SUCCESS { + return true + } + if firstErr == nil { + firstErr = errors.Errorf("%s: %w", msg, d.getError()) + } + return false + } + + E.DeliveryMode = DeliverPersistent + + var value *C.char + var length C.uint + if OK(C.dpiEnqOptions_getTransformation(opts, &value, &length), "getTransformation") { + E.Transformation = C.GoStringN(value, C.int(length)) + } + + var vis C.dpiVisibility + if OK(C.dpiEnqOptions_getVisibility(opts, &vis), "getVisibility") { + E.Visibility = Visibility(vis) + } + + return firstErr +} + +func (E EnqOptions) toOra(d *drv, opts *C.dpiEnqOptions) error { + var firstErr error + OK := func(ok C.int, msg string) bool { + if ok == C.DPI_SUCCESS { + return true + } + if firstErr == nil { + firstErr = errors.Errorf("%s: %w", msg, d.getError()) + } + return false + } + + OK(C.dpiEnqOptions_setDeliveryMode(opts, C.dpiMessageDeliveryMode(E.DeliveryMode)), "setDeliveryMode") + cs := C.CString(E.Transformation) + OK(C.dpiEnqOptions_setTransformation(opts, cs, C.uint(len(E.Transformation))), "setTransformation") + C.free(unsafe.Pointer(cs)) + OK(C.dpiEnqOptions_setVisibility(opts, C.uint(E.Visibility)), "setVisibility") + return firstErr +} + +// SetEnqOptions sets all the enqueue options +func (Q *Queue) SetEnqOptions(E EnqOptions) error { + var opts *C.dpiEnqOptions + if C.dpiQueue_getEnqOptions(Q.dpiQueue, &opts) == C.DPI_FAILURE { + return errors.Errorf("getEnqOptions: %w", Q.conn.drv.getError()) + } + return E.toOra(Q.conn.drv, opts) +} + +// DeqOptions are the options used to dequeue a message. +type DeqOptions struct { + Condition, Consumer, Correlation string + MsgID, Transformation string + Mode DeqMode + DeliveryMode DeliveryMode + Navigation DeqNavigation + Visibility Visibility + Wait uint32 +} + +func (D *DeqOptions) fromOra(d *drv, opts *C.dpiDeqOptions) error { + var firstErr error + OK := func(ok C.int, msg string) bool { + if ok == C.DPI_SUCCESS { + return true + } + if firstErr == nil { + firstErr = errors.Errorf("%s: %w", msg, d.getError()) + } + return false + } + + var value *C.char + var length C.uint + D.Transformation = "" + if OK(C.dpiDeqOptions_getTransformation(opts, &value, &length), "getTransformation") { + D.Transformation = C.GoStringN(value, C.int(length)) + } + D.Condition = "" + if OK(C.dpiDeqOptions_getCondition(opts, &value, &length), "getCondifion") { + D.Condition = C.GoStringN(value, C.int(length)) + } + D.Consumer = "" + if OK(C.dpiDeqOptions_getConsumerName(opts, &value, &length), "getConsumer") { + D.Consumer = C.GoStringN(value, C.int(length)) + } + D.Correlation = "" + if OK(C.dpiDeqOptions_getCorrelation(opts, &value, &length), "getCorrelation") { + D.Correlation = C.GoStringN(value, C.int(length)) + } + D.DeliveryMode = DeliverPersistent + var mode C.dpiDeqMode + if OK(C.dpiDeqOptions_getMode(opts, &mode), "getMode") { + D.Mode = DeqMode(mode) + } + D.MsgID = "" + if OK(C.dpiDeqOptions_getMsgId(opts, &value, &length), "getMsgId") { + D.MsgID = C.GoStringN(value, C.int(length)) + } + var nav C.dpiDeqNavigation + if OK(C.dpiDeqOptions_getNavigation(opts, &nav), "getNavigation") { + D.Navigation = DeqNavigation(nav) + } + var vis C.dpiVisibility + if OK(C.dpiDeqOptions_getVisibility(opts, &vis), "getVisibility") { + D.Visibility = Visibility(vis) + } + D.Wait = 0 + var u32 C.uint + if OK(C.dpiDeqOptions_getWait(opts, &u32), "getWait") { + D.Wait = uint32(u32) + } + return firstErr +} + +func (D DeqOptions) toOra(d *drv, opts *C.dpiDeqOptions) error { + var firstErr error + OK := func(ok C.int, msg string) bool { + if ok == C.DPI_SUCCESS { + return true + } + if firstErr == nil { + firstErr = errors.Errorf("%s: %w", msg, d.getError()) + } + return false + } + + cs := C.CString(D.Transformation) + OK(C.dpiDeqOptions_setTransformation(opts, cs, C.uint(len(D.Transformation))), "setTransformation") + C.free(unsafe.Pointer(cs)) + + cs = C.CString(D.Condition) + OK(C.dpiDeqOptions_setCondition(opts, cs, C.uint(len(D.Condition))), "setCondifion") + C.free(unsafe.Pointer(cs)) + + cs = C.CString(D.Consumer) + OK(C.dpiDeqOptions_setConsumerName(opts, cs, C.uint(len(D.Consumer))), "setConsumer") + C.free(unsafe.Pointer(cs)) + + cs = C.CString(D.Correlation) + OK(C.dpiDeqOptions_setCorrelation(opts, cs, C.uint(len(D.Correlation))), "setCorrelation") + C.free(unsafe.Pointer(cs)) + + OK(C.dpiDeqOptions_setDeliveryMode(opts, C.dpiMessageDeliveryMode(D.DeliveryMode)), "setDeliveryMode") + OK(C.dpiDeqOptions_setMode(opts, C.dpiDeqMode(D.Mode)), "setMode") + + cs = C.CString(D.MsgID) + OK(C.dpiDeqOptions_setMsgId(opts, cs, C.uint(len(D.MsgID))), "setMsgId") + C.free(unsafe.Pointer(cs)) + + OK(C.dpiDeqOptions_setNavigation(opts, C.dpiDeqNavigation(D.Navigation)), "setNavigation") + + OK(C.dpiDeqOptions_setVisibility(opts, C.dpiVisibility(D.Visibility)), "setVisibility") + + OK(C.dpiDeqOptions_setWait(opts, C.uint(D.Wait)), "setWait") + + return firstErr +} + +// SetDeqOptions sets all the dequeue options +func (Q *Queue) SetDeqOptions(D DeqOptions) error { + var opts *C.dpiDeqOptions + if C.dpiQueue_getDeqOptions(Q.dpiQueue, &opts) == C.DPI_FAILURE { + return errors.Errorf("getDeqOptions: %w", Q.conn.drv.getError()) + } + return D.toOra(Q.conn.drv, opts) +} + +// SetDeqCorrelation is a convenience function setting the Correlation DeqOption +func (Q *Queue) SetDeqCorrelation(correlation string) error { + var opts *C.dpiDeqOptions + if C.dpiQueue_getDeqOptions(Q.dpiQueue, &opts) == C.DPI_FAILURE { + return errors.Errorf("getDeqOptions: %w", Q.conn.drv.getError()) + } + cs := C.CString(correlation) + ok := C.dpiDeqOptions_setCorrelation(opts, cs, C.uint(len(correlation))) == C.DPI_FAILURE + C.free(unsafe.Pointer(cs)) + if !ok { + return errors.Errorf("setCorrelation: %w", Q.conn.drv.getError()) + } + return nil +} + +const ( + NoWait = uint32(0) + WaitForever = uint32(1<<31 - 1) +) + +// MessageState constants representing message's state. +type MessageState uint32 + +const ( + // MsgStateReady says that "The message is ready to be processed". + MsgStateReady = MessageState(C.DPI_MSG_STATE_READY) + // MsgStateWaiting says that "The message is waiting for the delay time to expire". + MsgStateWaiting = MessageState(C.DPI_MSG_STATE_WAITING) + // MsgStateProcessed says that "The message has already been processed and is retained". + MsgStateProcessed = MessageState(C.DPI_MSG_STATE_PROCESSED) + // MsgStateExpired says that "The message has been moved to the exception queue". + MsgStateExpired = MessageState(C.DPI_MSG_STATE_EXPIRED) +) + +// DeliveryMode constants for delivery modes. +type DeliveryMode uint32 + +const ( + // DeliverPersistent is to Dequeue only persistent messages from the queue. This is the default mode. + DeliverPersistent = DeliveryMode(C.DPI_MODE_MSG_PERSISTENT) + // DeliverBuffered is to Dequeue only buffered messages from the queue. + DeliverBuffered = DeliveryMode(C.DPI_MODE_MSG_BUFFERED) + // DeliverPersistentOrBuffered is to Dequeue both persistent and buffered messages from the queue. + DeliverPersistentOrBuffered = DeliveryMode(C.DPI_MODE_MSG_PERSISTENT_OR_BUFFERED) +) + +// Visibility constants represents visibility. +type Visibility uint32 + +const ( + // VisibleImmediate means that "The message is not part of the current transaction but constitutes a transaction of its own". + VisibleImmediate = Visibility(C.DPI_VISIBILITY_IMMEDIATE) + // VisibleOnCommit means that "The message is part of the current transaction. This is the default value". + VisibleOnCommit = Visibility(C.DPI_VISIBILITY_ON_COMMIT) +) + +// DeqMode constants for dequeue modes. +type DeqMode uint32 + +const ( + // DeqRemove reads the message and updates or deletes it. This is the default mode. Note that the message may be retained in the queue table based on retention properties. + DeqRemove = DeqMode(C.DPI_MODE_DEQ_REMOVE) + // DeqBrows reads the message without acquiring a lock on the message (equivalent to a SELECT statement). + DeqBrowse = DeqMode(C.DPI_MODE_DEQ_BROWSE) + // DeqLocked reads the message and obtain a write lock on the message (equivalent to a SELECT FOR UPDATE statement). + DeqLocked = DeqMode(C.DPI_MODE_DEQ_LOCKED) + // DeqPeek confirms receipt of the message but does not deliver the actual message content. + DeqPeek = DeqMode(C.DPI_MODE_DEQ_REMOVE_NO_DATA) +) + +// DeqNavigation constants for navigation. +type DeqNavigation uint32 + +const ( + // NavFirst retrieves the first available message that matches the search criteria. This resets the position to the beginning of the queue. + NavFirst = DeqNavigation(C.DPI_DEQ_NAV_FIRST_MSG) + // NavNext skips the remainder of the current transaction group (if any) and retrieves the first message of the next transaction group. This option can only be used if message grouping is enabled for the queue. + NavNextTran = DeqNavigation(C.DPI_DEQ_NAV_NEXT_TRANSACTION) + // NavNext Retrieves the next available message that matches the search criteria. This is the default method. + NavNext = DeqNavigation(C.DPI_DEQ_NAV_NEXT_MSG) +) diff --git a/vendor/gopkg.in/goracle.v2/rows.go b/vendor/github.com/godror/godror/rows.go similarity index 92% rename from vendor/gopkg.in/goracle.v2/rows.go rename to vendor/github.com/godror/godror/rows.go index 6b54d821f34..e870338d773 100644 --- a/vendor/gopkg.in/goracle.v2/rows.go +++ b/vendor/github.com/godror/godror/rows.go @@ -1,19 +1,9 @@ // Copyright 2017 Tamás Gulácsi // // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-License-Identifier: UPL-1.0 OR Apache-2.0 -package goracle +package godror /* #include "dpiImpl.h" @@ -30,7 +20,7 @@ import ( "time" "unsafe" - "github.com/pkg/errors" + errors "golang.org/x/xerrors" ) var _ = driver.Rows((*rows)(nil)) @@ -72,17 +62,16 @@ func (r *rows) Close() error { if r == nil { return nil } - r.columns = nil - r.data = nil - for _, v := range r.vars { - C.dpiVar_release(v) + vars, st := r.vars, r.statement + r.columns, r.vars, r.data, r.statement, r.nextRs = nil, nil, nil, nil, nil + for _, v := range vars[:cap(vars)] { + if v != nil { + C.dpiVar_release(v) + } } - r.vars = nil - if r.statement == nil { + if st == nil { return nil } - st := r.statement - r.statement = nil st.Lock() defer st.Unlock() @@ -91,7 +80,7 @@ func (r *rows) Close() error { } var err error if C.dpiStmt_release(st.dpiStmt) == C.DPI_FAILURE { - err = errors.Wrap(r.getError(), "rows/dpiStmt_release") + err = errors.Errorf("rows/dpiStmt_release: %w", r.getError()) } return err } @@ -266,6 +255,8 @@ func (r *rows) ColumnTypeScanType(index int) reflect.Type { // size as the Columns() are wide. // // Next should return io.EOF when there are no more rows. +// +// As with all Objects, you MUST call Close on the returned Object instances when they're not needed anymore! func (r *rows) Next(dest []driver.Value) error { if r.err != nil { return r.err @@ -280,7 +271,7 @@ func (r *rows) Next(dest []driver.Value) error { if r.fetched == 0 { var moreRows C.int if C.dpiStmt_fetchRows(r.dpiStmt, C.uint32_t(r.statement.FetchRowCount()), &r.bufferRowIndex, &r.fetched, &moreRows) == C.DPI_FAILURE { - return errors.Wrap(r.getError(), "Next") + return errors.Errorf("Next: %w", r.getError()) } if Log != nil { Log("msg", "fetched", "bri", r.bufferRowIndex, "fetched", r.fetched, "moreRows", moreRows, "len(data)", len(r.data), "cols", len(r.columns)) @@ -296,7 +287,7 @@ func (r *rows) Next(dest []driver.Value) error { var n C.uint32_t var data *C.dpiData if C.dpiVar_getReturnedData(r.vars[i], 0, &n, &data) == C.DPI_FAILURE { - return errors.Wrapf(r.getError(), "getReturnedData[%d]", i) + return errors.Errorf("getReturnedData[%d]: %w", i, r.getError()) } r.data[i] = (*[maxArraySize]C.dpiData)(unsafe.Pointer(data))[:n:n] //fmt.Printf("data %d=%+v\n%+v\n", n, data, r.data[i][0]) @@ -313,7 +304,7 @@ func (r *rows) Next(dest []driver.Value) error { typ := col.OracleType d := &r.data[i][r.bufferRowIndex] isNull := d.isNull == 1 - if Log != nil { + if false && Log != nil { Log("msg", "Next", "i", i, "row", r.bufferRowIndex, "typ", typ, "null", isNull) //, "data", fmt.Sprintf("%+v", d), "typ", typ) } @@ -352,7 +343,12 @@ func (r *rows) Next(dest []driver.Value) error { dest[i] = printFloat(float64(C.dpiData_getDouble(d))) default: b := C.dpiData_getBytes(d) - dest[i] = Number(C.GoStringN(b.ptr, C.int(b.length))) + s := C.GoStringN(b.ptr, C.int(b.length)) + if r.NumberAsString() { + dest[i] = s + } else { + dest[i] = Number(s) + } if Log != nil { Log("msg", "b", "i", i, "ptr", b.ptr, "length", b.length, "typ", col.NativeType, "int64", C.dpiData_getInt64(d), "dest", dest[i]) } @@ -436,7 +432,7 @@ func (r *rows) Next(dest []driver.Value) error { C.DPI_NATIVE_TYPE_LOB: isClob := typ == C.DPI_ORACLE_TYPE_CLOB || typ == C.DPI_ORACLE_TYPE_NCLOB if isNull { - if isClob && r.ClobAsString() { + if isClob && (r.ClobAsString() || !r.LobAsReader()) { dest[i] = "" } else { dest[i] = nil @@ -444,9 +440,11 @@ func (r *rows) Next(dest []driver.Value) error { continue } rdr := &dpiLobReader{dpiLob: C.dpiData_getLOB(d), conn: r.conn, IsClob: isClob} - if isClob && r.ClobAsString() { + if isClob && (r.ClobAsString() || !r.LobAsReader()) { sb := stringBuilders.Get() - if _, err := io.Copy(sb, rdr); err != nil { + _, err := io.Copy(sb, rdr) + C.dpiLob_close(rdr.dpiLob) + if err != nil { stringBuilders.Put(sb) return err } @@ -466,7 +464,7 @@ func (r *rows) Next(dest []driver.Value) error { } var colCount C.uint32_t if C.dpiStmt_getNumQueryColumns(st.dpiStmt, &colCount) == C.DPI_FAILURE { - return errors.Wrap(r.getError(), "getNumQueryColumns") + return errors.Errorf("getNumQueryColumns: %w", r.getError()) } st.Lock() r2, err := st.openRows(int(colCount)) @@ -488,7 +486,7 @@ func (r *rows) Next(dest []driver.Value) error { dest[i] = nil continue } - o, err := wrapObject(r.drv, col.ObjectType, C.dpiData_getObject(d)) + o, err := wrapObject(r.conn, col.ObjectType, C.dpiData_getObject(d)) if err != nil { return err } @@ -503,6 +501,10 @@ func (r *rows) Next(dest []driver.Value) error { r.bufferRowIndex++ r.fetched-- + if Log != nil { + Log("msg", "scanned", "row", r.bufferRowIndex, "dest", dest) + } + return nil } @@ -562,7 +564,7 @@ func (r *rows) getImplicitResult() { r.origSt = st } if C.dpiStmt_getImplicitResult(st.dpiStmt, &r.nextRs) == C.DPI_FAILURE { - r.nextRsErr = errors.Wrap(r.getError(), "getImplicitResult") + r.nextRsErr = errors.Errorf("getImplicitResult: %w", r.getError()) } } func (r *rows) HasNextResultSet() bool { @@ -586,14 +588,14 @@ func (r *rows) NextResultSet() error { return r.nextRsErr } if r.nextRs == nil { - return errors.Wrap(io.EOF, "getImplicitResult") + return errors.Errorf("getImplicitResult: %w", io.EOF) } } st := &statement{conn: r.conn, dpiStmt: r.nextRs} var n C.uint32_t if C.dpiStmt_getNumQueryColumns(st.dpiStmt, &n) == C.DPI_FAILURE { - return errors.Wrapf(io.EOF, "getNumQueryColumns: %v", r.getError()) + return errors.Errorf("getNumQueryColumns: %w: %w", r.getError(), io.EOF) } // keep the originam statement for the succeeding NextResultSet calls. nr, err := st.openRows(int(n)) diff --git a/vendor/github.com/godror/godror/sid/sid.go b/vendor/github.com/godror/godror/sid/sid.go new file mode 100644 index 00000000000..b1fb0953142 --- /dev/null +++ b/vendor/github.com/godror/godror/sid/sid.go @@ -0,0 +1,531 @@ +// Copyright 2019 Tamás Gulácsi +// +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LIENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR ONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package sid + +import ( + "fmt" + "io" + "strconv" + "strings" + "unicode" + + errors "golang.org/x/xerrors" +) + +// Statement can Parse and Print Oracle connection descriptor (DESRIPTION=(ADDRESS=...)) format. +// It can be used to parse or build a SID. +// +// See https://docs.oracle.com/cd/B28359_01/network.111/b28317/tnsnames.htm#NETRF271 +type Statement struct { + Name, Value string + Statements []Statement +} + +func (cs Statement) String() string { + var buf strings.Builder + cs.Print(&buf, "\n", " ") + return buf.String() +} +func (cs Statement) Print(w io.Writer, prefix, indent string) { + fmt.Fprintf(w, "%s(%s=%s", prefix, cs.Name, cs.Value) + if cs.Value == "" { + for _, s := range cs.Statements { + s.Print(w, prefix+indent, indent) + } + } + io.WriteString(w, ")") +} + +func ParseConnDescription(s string) (Statement, error) { + var cs Statement + _, err := cs.Parse(s) + return cs, err +} +func (cs *Statement) Parse(s string) (string, error) { + ltrim := func(s string) string { return strings.TrimLeftFunc(s, unicode.IsSpace) } + s = ltrim(s) + if s == "" || s[0] != '(' { + return s, nil + } + i := strings.IndexByte(s[1:], '=') + 1 + if i <= 0 || strings.Contains(s[1:i], ")") { + return s, errors.Errorf("no = after ( in %q", s) + } + cs.Name = s[1:i] + s = ltrim(s[i+1:]) + + if s == "" { + return s, nil + } + if s[0] != '(' { + if i = strings.IndexByte(s, ')'); i < 0 || strings.Contains(s[1:i], "(") { + return s, errors.Errorf("no ) after = in %q", s) + } + cs.Value = s[:i] + s = ltrim(s[i+1:]) + return s, nil + } + + for s != "" && s[0] == '(' { + var sub Statement + var err error + if s, err = sub.Parse(s); err != nil { + return s, err + } + if sub.Name == "" { + break + } + cs.Statements = append(cs.Statements, sub) + } + s = ltrim(s) + if s != "" && s[0] == ')' { + s = ltrim(s[1:]) + } + return s, nil +} + +type DescriptionList struct { + Options ListOptions + Descriptions []Description + TypeOfService string +} + +func (cd DescriptionList) Print(w io.Writer, prefix, indent string) { + io.WriteString(w, prefix+"(DESCRIPTION_LIST=") + cd.Options.Print(w, prefix, indent) + for _, d := range cd.Descriptions { + d.Print(w, prefix, indent) + } + if cd.TypeOfService != "" { + fmt.Fprintf(w, "%s(TYPE_OF_SERVICE=%s)", prefix, cd.TypeOfService) + } + io.WriteString(w, ")") +} +func (cd *DescriptionList) Parse(ss []Statement) error { + if len(ss) == 1 && ss[0].Name == "DESCRIPTION_LIST" { + ss = ss[0].Statements + } + cd.TypeOfService = "" + if err := cd.Options.Parse(ss); err != nil { + return err + } + cd.Descriptions = cd.Descriptions[:0] + for _, s := range ss { + switch s.Name { + case "DESCRIPTION": + var d Description + if err := d.Parse(s.Statements); err != nil { + return err + } + cd.Descriptions = append(cd.Descriptions, d) + case "TYPE_OF_SERVICE": + cd.TypeOfService = s.Value + } + } + return cd.Options.Parse(ss) +} + +type Description struct { + TCPKeepAlive bool + SDU int + Bufs BufSizes + Options ListOptions + Addresses []Address + AddressList AddressList + ConnectData ConnectData + TypeOfService string + Security Security +} + +func (d Description) Print(w io.Writer, prefix, indent string) { + if d.IsZero() { + return + } + io.WriteString(w, prefix+"(DESCRIPTION=") + if d.TCPKeepAlive { + io.WriteString(w, prefix+"(ENABLE=broken)") + } + if d.SDU != 0 { + fmt.Fprintf(w, prefix+"(SDU=%d)", d.SDU) + } + d.Bufs.Print(w, prefix, indent) + d.Options.Print(w, prefix, indent) + for _, a := range d.Addresses { + a.Print(w, prefix, indent) + } + d.AddressList.Print(w, prefix, indent) + d.ConnectData.Print(w, prefix, indent) + if d.TypeOfService != "" { + fmt.Fprintf(w, "%s(TYPE_OF_SERVICE=%s)", prefix, d.TypeOfService) + } + d.Security.Print(w, prefix, indent) + io.WriteString(w, ")") +} +func (d Description) IsZero() bool { + return !d.TCPKeepAlive && d.SDU == 0 && d.Bufs.IsZero() && d.Options.IsZero() && len(d.Addresses) == 0 && d.AddressList.IsZero() && d.ConnectData.IsZero() && d.TypeOfService == "" && d.Security.IsZero() +} +func (d *Description) Parse(ss []Statement) error { + if len(ss) == 1 && ss[0].Name == "DESCRIPTION" { + ss = ss[0].Statements + } + d.TCPKeepAlive, d.SDU = false, 0 + for _, s := range ss { + switch s.Name { + case "ADDRESS": + var a Address + if err := a.Parse(s.Statements); err != nil { + return err + } + if !a.IsZero() { + d.Addresses = append(d.Addresses, a) + } + case "ADDRESS_LIST": + if err := d.AddressList.Parse(s.Statements); err != nil { + return err + } + case "CONNECT_DATA": + if err := d.ConnectData.Parse(s.Statements); err != nil { + return err + } + case "ENABLE": + d.TCPKeepAlive = d.TCPKeepAlive || s.Value == "broken" + case "SDU": + var err error + if d.SDU, err = strconv.Atoi(s.Value); err != nil { + return err + } + case "SECURITY": + if err := d.Security.Parse(s.Statements); err != nil { + return err + } + } + } + if err := d.Bufs.Parse(ss); err != nil { + return err + } + if err := d.Options.Parse(ss); err != nil { + return err + } + return nil +} + +type Address struct { + Protocol, Host string + Port int + BufSizes +} + +func (a Address) Print(w io.Writer, prefix, indent string) { + if a.IsZero() { + return + } + io.WriteString(w, prefix+"(ADDRESS=") + if a.Protocol != "" { + fmt.Fprintf(w, "%s(PROTOCOL=%s)", prefix, a.Protocol) + } + if a.Host != "" { + fmt.Fprintf(w, "%s(HOST=%s)", prefix, a.Host) + } + if a.Port != 0 { + fmt.Fprintf(w, "%s(PORT=%d)", prefix, a.Port) + } + a.BufSizes.Print(w, prefix, indent) + io.WriteString(w, ")") +} +func (a Address) IsZero() bool { + return a.Protocol == "" && a.Host == "" && a.Port == 0 && a.BufSizes.IsZero() +} +func (a *Address) Parse(ss []Statement) error { + if len(ss) == 1 && ss[0].Name == "ADDRESS" { + ss = ss[0].Statements + } + for _, s := range ss { + switch s.Name { + case "PROTOCOL": + a.Protocol = s.Value + case "HOST": + a.Host = s.Value + case "PORT": + i, err := strconv.Atoi(s.Value) + if err != nil { + return err + } + a.Port = i + } + } + return a.BufSizes.Parse(ss) +} + +type BufSizes struct { + RecvBufSize, SendBufSize int +} + +func (bs BufSizes) Print(w io.Writer, prefix, indent string) { + if bs.RecvBufSize > 0 { + fmt.Fprintf(w, "%s(RECV_BUF_SIZE=%d)", prefix, bs.RecvBufSize) + } + if bs.SendBufSize > 0 { + fmt.Fprintf(w, "%s(SEND_BUF_SIZE=%d)", prefix, bs.SendBufSize) + } +} +func (bs BufSizes) IsZero() bool { return bs.RecvBufSize > 0 && bs.SendBufSize > 0 } +func (bs *BufSizes) Parse(ss []Statement) error { + for _, s := range ss { + switch s.Name { + case "RECV_BUF_SIZE", "SEND_BUF_SIZE": + i, err := strconv.Atoi(s.Value) + if err != nil { + return err + } + if s.Name == "RECV_BUF_SIZE" { + bs.RecvBufSize = i + } else { + bs.SendBufSize = i + } + } + } + return nil +} + +type ListOptions struct { + Failover, LoadBalance, SourceRoute bool +} + +func (lo ListOptions) Print(w io.Writer, prefix, indent string) { + if lo.Failover { + io.WriteString(w, prefix+"(FAILOVER=on)") + } + if lo.LoadBalance { + io.WriteString(w, prefix+"(LOAD_BALANE=on)") + } + if lo.SourceRoute { + io.WriteString(w, prefix+"(SOURE_ROUTE=on)") + } +} +func (lo ListOptions) IsZero() bool { return !lo.Failover && !lo.LoadBalance && !lo.SourceRoute } +func s2b(s string) bool { return s == "on" || s == "yes" || s == "true" } +func (lo *ListOptions) Parse(ss []Statement) error { + *lo = ListOptions{} + for _, s := range ss { + switch s.Name { + case "FAILOVER": + lo.Failover = s2b(s.Value) + case "LOAD_BALANE": + lo.LoadBalance = s2b(s.Value) + case "SourceRoute": + lo.SourceRoute = s2b(s.Value) + } + } + return nil +} + +type AddressList struct { + Options ListOptions + Addresses []Address +} + +func (al AddressList) Print(w io.Writer, prefix, indent string) { + if al.IsZero() { + return + } + io.WriteString(w, prefix+"(ADDRESS_LIST=") + al.Options.Print(w, prefix, indent) + for _, a := range al.Addresses { + a.Print(w, prefix, indent) + } + io.WriteString(w, ")") +} +func (al AddressList) IsZero() bool { return al.Options.IsZero() && len(al.Addresses) == 0 } +func (al *AddressList) Parse(ss []Statement) error { + if len(ss) == 1 && ss[0].Name == "ADDRESS_LIST" { + ss = ss[0].Statements + } + if err := al.Options.Parse(ss); err != nil { + return err + } + al.Addresses = al.Addresses[:0] + for _, s := range ss { + switch s.Name { + case "ADDRESS": + var a Address + if err := a.Parse(s.Statements); err != nil { + return err + } + if !a.IsZero() { + al.Addresses = append(al.Addresses, a) + } + } + } + return nil +} + +type ConnectData struct { + FailoverMode FailoverMode + ServiceName, SID string + GlobalName, InstanceName, RDBDatabase string + Hs bool + Server ServiceHandler +} + +func (cd ConnectData) Print(w io.Writer, prefix, indent string) { + if cd.IsZero() { + return + } + io.WriteString(w, prefix+"(CONNECT_DATA=") + cd.FailoverMode.Print(w, prefix, indent) + if cd.GlobalName != "" { + fmt.Fprintf(w, "%s(GLOBAL_NAME=%s)", prefix, cd.GlobalName) + } + if cd.InstanceName != "" { + fmt.Fprintf(w, "%s(INSTANCE_NAME=%s)", prefix, cd.InstanceName) + } + if cd.RDBDatabase != "" { + fmt.Fprintf(w, "%s(RDB_DATABASE=%s)", prefix, cd.RDBDatabase) + } + if cd.ServiceName != "" { + fmt.Fprintf(w, "%s(SERVICE_NAME=%s)", prefix, cd.ServiceName) + } + if cd.SID != "" { + fmt.Fprintf(w, "%s(SID=%s)", prefix, cd.SID) + } + if cd.Hs { + io.WriteString(w, prefix+"(HS=ok)") + } + if cd.Server != "" { + fmt.Fprintf(w, "%s(SERVER=%s)", prefix, cd.Server) + } + io.WriteString(w, ")") +} +func (cd ConnectData) IsZero() bool { + return cd.FailoverMode.IsZero() && cd.GlobalName == "" && cd.InstanceName == "" && cd.RDBDatabase == "" && cd.ServiceName == "" && cd.SID == "" && !cd.Hs && cd.Server == "" +} +func (cd *ConnectData) Parse(ss []Statement) error { + if len(ss) == 1 && ss[0].Name == "CONNECT_DATA" { + ss = ss[0].Statements + } + cd.Hs = false + for _, s := range ss { + switch s.Name { + case "FAILOVER_MODE": + if err := cd.FailoverMode.Parse(s.Statements); err != nil { + return err + } + case "GLOBAL_NAME": + cd.GlobalName = s.Value + case "INSTANCE_NAME": + cd.InstanceName = s.Value + case "RDB_DATABASE": + cd.RDBDatabase = s.Value + case "SERVICE_NAME": + cd.ServiceName = s.Value + case "SID": + cd.SID = s.Value + case "HS": + cd.Hs = s.Value == "ok" + case "SERVER": + cd.Server = ServiceHandler(s.Value) + } + } + return nil +} + +type FailoverMode struct { + Backup, Type, Method string + Retry, Delay int +} + +func (fo FailoverMode) Print(w io.Writer, prefix, indent string) { + if fo.IsZero() { + return + } + io.WriteString(w, prefix+"(FAILOVER_MODE=") + if fo.Backup != "" { + fmt.Fprintf(w, "%s(BACKUP=%s)", prefix, fo.Backup) + } + if fo.Type != "" { + fmt.Fprintf(w, "%s(TYPE=%s)", prefix, fo.Type) + } + if fo.Method != "" { + fmt.Fprintf(w, "%s(METHOD=%s)", prefix, fo.Method) + } + if fo.Retry != 0 { + fmt.Fprintf(w, "%s(RETRY=%d)", prefix, fo.Retry) + } + if fo.Delay != 0 { + fmt.Fprintf(w, "%s(DELAY=%d)", prefix, fo.Delay) + } + io.WriteString(w, ")") +} +func (fo FailoverMode) IsZero() bool { + return fo.Backup == "" && fo.Type == "" && fo.Method == "" && fo.Retry == 0 && fo.Delay == 0 +} +func (fo *FailoverMode) Parse(ss []Statement) error { + if len(ss) == 1 && ss[0].Name == "FAILOVER_MODE" { + ss = ss[0].Statements + } + for _, s := range ss { + switch s.Name { + case "BACKUP": + fo.Backup = s.Value + case "TYPE": + fo.Type = s.Value + case "METHOD": + fo.Method = s.Value + case "RETRY", "DELAY": + i, err := strconv.Atoi(s.Value) + if err != nil { + return err + } + if s.Name == "RETRY" { + fo.Retry = i + } else { + fo.Delay = i + } + } + } + return nil +} + +type ServiceHandler string + +const ( + Dedicated = ServiceHandler("dedicated") + Shared = ServiceHandler("shared") + Pooled = ServiceHandler("pooled") +) + +type Security struct { + SSLServerCertDN string +} + +func (sec Security) Print(w io.Writer, prefix, indent string) { + if sec.SSLServerCertDN != "" { + fmt.Fprintf(w, "%s(SECURITY=(SSL_SERVER_CERT_DN=%s))", prefix, sec.SSLServerCertDN) + } +} +func (sec Security) IsZero() bool { return sec.SSLServerCertDN == "" } +func (sec *Security) Parse(ss []Statement) error { + if len(ss) == 1 && ss[0].Name == "SECURITY" { + ss = ss[0].Statements + } + sec.SSLServerCertDN = "" + for _, s := range ss { + if s.Name == "SSL_SERVER_CERT_DN" { + sec.SSLServerCertDN = s.Value + } + } + return nil +} diff --git a/vendor/gopkg.in/goracle.v2/stmt.go b/vendor/github.com/godror/godror/stmt.go similarity index 87% rename from vendor/gopkg.in/goracle.v2/stmt.go rename to vendor/github.com/godror/godror/stmt.go index 6e8e6215365..3a2f6d291a1 100644 --- a/vendor/gopkg.in/goracle.v2/stmt.go +++ b/vendor/github.com/godror/godror/stmt.go @@ -1,25 +1,24 @@ // Copyright 2017 Tamás Gulácsi // // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-License-Identifier: UPL-1.0 OR Apache-2.0 -package goracle +package godror /* #include #include "dpiImpl.h" const int sizeof_dpiData = sizeof(void); + +void godror_setFromString(dpiVar *dv, uint32_t pos, const _GoString_ value) { + uint32_t length; + length = _GoStringLen(value); + if( length == 0 ) { + return; + } + dpiVar_setFromBytes(dv, pos, _GoStringPtr(value), length); +} */ import "C" import ( @@ -30,11 +29,12 @@ import ( "io" "reflect" "strconv" + "strings" "sync" "time" "unsafe" - "github.com/pkg/errors" + errors "golang.org/x/xerrors" ) type stmtOptions struct { @@ -45,6 +45,7 @@ type stmtOptions struct { plSQLArrays bool lobAsReader bool magicTypeConversion bool + numberAsString bool } func (o stmtOptions) ExecMode() C.dpiExecMode { @@ -55,8 +56,10 @@ func (o stmtOptions) ExecMode() C.dpiExecMode { } func (o stmtOptions) ArraySize() int { - if o.arraySize <= 0 || o.arraySize > 32<<10 { + if o.arraySize <= 0 { return DefaultArraySize + } else if o.arraySize > 1<<16 { + return 1 << 16 } return o.arraySize } @@ -72,6 +75,7 @@ func (o stmtOptions) ClobAsString() bool { return !o.lobAsReader } func (o stmtOptions) LobAsReader() bool { return o.lobAsReader } func (o stmtOptions) MagicTypeConversion() bool { return o.magicTypeConversion } +func (o stmtOptions) NumberAsString() bool { return o.numberAsString } // Option holds statement options. type Option func(*stmtOptions) @@ -135,6 +139,11 @@ func MagicTypeConversion() Option { return func(o *stmtOptions) { o.magicTypeConversion = true } } +// NumberAsString returns an option to return numbers as string, not Number. +func NumberAsString() Option { + return func(o *stmtOptions) { o.numberAsString = true } +} + // CallTimeout sets the round-trip timeout (OCI_ATTR_CALL_TIMEOUT). // // See https://docs.oracle.com/en/database/oracle/oracle-database/18/lnoci/handle-and-descriptor-attributes.html#GUID-D8EE68EB-7E38-4068-B06E-DF5686379E5E @@ -178,36 +187,16 @@ func (st *statement) Close() error { st.Lock() defer st.Unlock() - return st.close() + return st.close(false) } -func (st *statement) close() error { +func (st *statement) close(keepDpiStmt bool) error { if st == nil { return nil } - dpiStmt := st.dpiStmt - c := st.conn - st.cleanup() - var si C.dpiStmtInfo - if dpiStmt != nil && - C.dpiStmt_getInfo(dpiStmt, &si) != C.DPI_FAILURE && // this is just to check the validity of dpiStmt, to avoid SIGSEGV - C.dpiStmt_release(dpiStmt) != C.DPI_FAILURE { - return nil - } - if c == nil { - return driver.ErrBadConn - } - return errors.Wrap(c.getError(), "statement/dpiStmt_release") -} - -func (st *statement) cleanup() error { - if st == nil { - return nil - } - - for _, v := range st.vars { - C.dpiVar_release(v) - } + c, dpiStmt, vars := st.conn, st.dpiStmt, st.vars + st.isSlice = nil + st.query = "" st.data = nil st.vars = nil st.varInfos = nil @@ -215,13 +204,29 @@ func (st *statement) cleanup() error { st.dests = nil st.columns = nil st.dpiStmt = nil - c := st.conn st.conn = nil + for _, v := range vars[:cap(vars)] { + if v != nil { + C.dpiVar_release(v) + } + } + + if !keepDpiStmt { + var si C.dpiStmtInfo + if dpiStmt != nil && + C.dpiStmt_getInfo(dpiStmt, &si) != C.DPI_FAILURE && // this is just to check the validity of dpiStmt, to avoid SIGSEGV + C.dpiStmt_release(dpiStmt) != C.DPI_FAILURE { + return nil + } + } if c == nil { return driver.ErrBadConn } - return errors.Wrap(c.getError(), "statement/dpiStmt_release") + if err := c.getError(); err != nil { + return errors.Errorf("statement/dpiStmt_release: %w", err) + } + return nil } // Exec executes a query that doesn't return rows, such @@ -253,6 +258,8 @@ func (st *statement) Query(args []driver.Value) (driver.Rows, error) { // ExecContext executes a query that doesn't return rows, such as an INSERT or UPDATE. // // ExecContext must honor the context timeout and return when it is canceled. +// +// Cancelation/timeout is honored, execution is broken, but you may have to disable out-of-bound execution - see https://github.com/oracle/odpi/issues/116 for details. func (st *statement) ExecContext(ctx context.Context, args []driver.NamedValue) (res driver.Result, err error) { if err = ctx.Err(); err != nil { return nil, err @@ -262,9 +269,10 @@ func (st *statement) ExecContext(ctx context.Context, args []driver.NamedValue) closeIfBadConn := func(err error) error { if err != nil && err == driver.ErrBadConn { if Log != nil { - Log("error", driver.ErrBadConn) + Log("error", err) } - st.close() + st.close(false) + st.conn.close(true) } return err } @@ -277,8 +285,8 @@ func (st *statement) ExecContext(ctx context.Context, args []driver.NamedValue) } st.isReturning = false - st.conn.RLock() - defer st.conn.RUnlock() + st.conn.mu.RLock() + defer st.conn.mu.RUnlock() // bind variables if err = st.bindVars(args, Log); err != nil { @@ -296,6 +304,7 @@ func (st *statement) ExecContext(ctx context.Context, args []driver.NamedValue) // execute go func() { defer close(done) + var err error Loop: for i := 0; i < 3; i++ { if err = ctx.Err(); err != nil { @@ -328,15 +337,13 @@ func (st *statement) ExecContext(ctx context.Context, args []driver.NamedValue) if err == nil { var info C.dpiStmtInfo if C.dpiStmt_getInfo(st.dpiStmt, &info) == C.DPI_FAILURE { - err = errors.Wrap(st.getError(), "getInfo") + err = errors.Errorf("getInfo: %w", st.getError()) } st.isReturning = info.isReturning != 0 - return + break } - cdr, ok := errors.Cause(err).(interface { - Code() int - }) - if !ok { + var cdr interface{ Code() int } + if !errors.As(err, &cdr) { break } switch code := cdr.Code(); code { @@ -349,7 +356,11 @@ func (st *statement) ExecContext(ctx context.Context, args []driver.NamedValue) } break } - done <- maybeBadConn(errors.Wrapf(err, "dpiStmt_execute(mode=%d arrLen=%d)", mode, st.arrLen)) + if err == nil { + done <- nil + return + } + done <- maybeBadConn(errors.Errorf("dpiStmt_execute(mode=%d arrLen=%d): %w", mode, st.arrLen, err), nil) }() select { @@ -369,8 +380,13 @@ func (st *statement) ExecContext(ctx context.Context, args []driver.NamedValue) Log("msg", "BREAK statement") } _ = st.Break() - st.cleanup() - return nil, driver.ErrBadConn + // For some reasons this SIGSEGVs if not not keepDpiStmt (try to close it), + st.close(true) + // so we hope that the following conn.Close closes the dpiStmt, too. + if err := st.conn.Close(); err != nil { + return nil, err + } + return nil, ctx.Err() } } @@ -386,7 +402,7 @@ func (st *statement) ExecContext(ctx context.Context, args []driver.NamedValue) data := &st.data[i][0] if C.dpiVar_getReturnedData(st.vars[i], 0, &n, &data) == C.DPI_FAILURE { err = st.getError() - return nil, errors.Wrapf(closeIfBadConn(err), "%d.getReturnedData", i) + return nil, errors.Errorf("%d.getReturnedData: %w", i, closeIfBadConn(err)) } if n == 0 { st.data[i] = st.data[i][:0] @@ -400,7 +416,7 @@ func (st *statement) ExecContext(ctx context.Context, args []driver.NamedValue) if Log != nil { Log("get", i, "error", err) } - return nil, errors.Wrapf(closeIfBadConn(err), "%d. get[%d]", i, 0) + return nil, errors.Errorf("%d. get[%d]: %w", i, 0, closeIfBadConn(err)) } continue } @@ -410,14 +426,14 @@ func (st *statement) ExecContext(ctx context.Context, args []driver.NamedValue) if Log != nil { Log("msg", "getNumElementsInArray", "i", i, "error", err) } - return nil, errors.Wrapf(closeIfBadConn(err), "%d.getNumElementsInArray", i) + return nil, errors.Errorf("%d.getNumElementsInArray: %w", i, closeIfBadConn(err)) } //fmt.Printf("i=%d dest=%T %#v\n", i, dest, dest) if err = get(dest, st.data[i][:n]); err != nil { if Log != nil { Log("msg", "get", "i", i, "n", n, "error", err) } - return nil, errors.Wrapf(closeIfBadConn(err), "%d. get", i) + return nil, errors.Errorf("%d. get: %w", i, closeIfBadConn(err)) } } var count C.uint64_t @@ -430,6 +446,8 @@ func (st *statement) ExecContext(ctx context.Context, args []driver.NamedValue) // QueryContext executes a query that may return rows, such as a SELECT. // // QueryContext must honor the context timeout and return when it is canceled. +// +// Cancelation/timeout is honored, execution is broken, but you may have to disable out-of-bound execution - see https://github.com/oracle/odpi/issues/116 for details. func (st *statement) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) { if err := ctx.Err(); err != nil { return nil, err @@ -438,7 +456,11 @@ func (st *statement) QueryContext(ctx context.Context, args []driver.NamedValue) closeIfBadConn := func(err error) error { if err != nil && err == driver.ErrBadConn { - st.close() + if Log != nil { + Log("error", err) + } + st.close(false) + st.conn.close(true) } return err } @@ -446,8 +468,8 @@ func (st *statement) QueryContext(ctx context.Context, args []driver.NamedValue) st.Lock() defer st.Unlock() st.isReturning = false - st.conn.RLock() - defer st.conn.RUnlock() + st.conn.mu.RLock() + defer st.conn.mu.RUnlock() switch st.query { case getConnection: @@ -469,6 +491,12 @@ func (st *statement) QueryContext(ctx context.Context, args []driver.NamedValue) return nil, closeIfBadConn(err) } + mode := st.ExecMode() + //fmt.Printf("%p.%p: inTran? %t\n%s\n", st.conn, st, st.inTransaction, st.query) + if !st.inTransaction { + mode |= C.DPI_MODE_EXEC_COMMIT_ON_SUCCESS + } + // execute var colCount C.uint32_t done := make(chan error, 1) @@ -481,7 +509,7 @@ func (st *statement) QueryContext(ctx context.Context, args []driver.NamedValue) return } st.setCallTimeout(ctx) - if C.dpiStmt_execute(st.dpiStmt, st.ExecMode(), &colCount) != C.DPI_FAILURE { + if C.dpiStmt_execute(st.dpiStmt, mode, &colCount) != C.DPI_FAILURE { break } if err = ctx.Err(); err == nil { @@ -491,7 +519,11 @@ func (st *statement) QueryContext(ctx context.Context, args []driver.NamedValue) } } } - done <- maybeBadConn(errors.Wrap(err, "dpiStmt_execute")) + if err == nil { + done <- nil + return + } + done <- maybeBadConn(errors.Errorf("dpiStmt_execute: %w", err), nil) }() select { @@ -510,8 +542,13 @@ func (st *statement) QueryContext(ctx context.Context, args []driver.NamedValue) Log("msg", "BREAK query") } _ = st.Break() - st.cleanup() - return nil, driver.ErrBadConn + // For some reasons this SIGSEGVs if not not keepDpiStmt (try to close it), + st.close(true) + // so we hope that the following conn.Close closes the dpiStmt, too. + if err := st.conn.Close(); err != nil { + return nil, err + } + return nil, ctx.Err() } } rows, err := st.openRows(int(colCount)) @@ -539,10 +576,6 @@ func (st *statement) NumInput() int { return 0 } - if !go10 { - return -1 - } - st.Lock() defer st.Unlock() var cnt C.uint32_t @@ -587,12 +620,10 @@ func (st *statement) bindVars(args []driver.NamedValue, Log logFunc) error { if Log != nil { Log("enter", "bindVars", "args", args) } - if cap(st.vars) < len(args) || cap(st.varInfos) < len(args) { - for i, v := range st.vars { - if v != nil { - C.dpiVar_release(v) - st.vars[i], st.varInfos[i] = nil, varInfo{} - } + for i, v := range st.vars[:cap(st.vars)] { + if v != nil { + C.dpiVar_release(v) + st.vars[i], st.varInfos[i] = nil, varInfo{} } } var named bool @@ -713,7 +744,7 @@ func (st *statement) bindVars(args []driver.NamedValue, Log logFunc) error { var err error if value, err = st.bindVarTypeSwitch(info, &(st.gets[i]), value); err != nil { - return errors.Wrapf(err, "%d. arg", i+1) + return errors.Errorf("%d. arg: %w", i+1, err) } var rv reflect.Value @@ -742,12 +773,8 @@ func (st *statement) bindVars(args []driver.NamedValue, Log logFunc) error { return errors.Errorf("maximum array size allowed is %d", maxArraySize) } if st.vars[i] == nil || st.data[i] == nil || st.varInfos[i] != vi { - if st.vars[i] != nil { - C.dpiVar_release(st.vars[i]) - st.vars[i] = nil - } if st.vars[i], st.data[i], err = st.newVar(vi); err != nil { - return errors.WithMessage(err, fmt.Sprintf("%d", i)) + return errors.Errorf("%d: %w", i, err) } st.varInfos[i] = vi } @@ -760,7 +787,7 @@ func (st *statement) bindVars(args []driver.NamedValue, Log logFunc) error { Log("C", "dpiVar_setNumElementsInArray", "i", i, "n", 0) } if C.dpiVar_setNumElementsInArray(dv, C.uint32_t(0)) == C.DPI_FAILURE { - return errors.Wrapf(st.getError(), "setNumElementsInArray[%d](%d)", i, 0) + return errors.Errorf("setNumElementsInArray[%d](%d): %w", i, 0, st.getError()) } } continue @@ -771,7 +798,7 @@ func (st *statement) bindVars(args []driver.NamedValue, Log logFunc) error { Log("msg", "set", "i", i, "value", fmt.Sprintf("%T=%#v", value, value)) } if err := info.set(dv, data[:1], value); err != nil { - return errors.Wrapf(err, "set(data[%d][%d], %#v (%T))", i, 0, value, value) + return errors.Errorf("set(data[%d][%d], %#v (%T)): %w", i, 0, value, value, err) } continue } @@ -783,7 +810,7 @@ func (st *statement) bindVars(args []driver.NamedValue, Log logFunc) error { Log("C", "dpiVar_setNumElementsInArray", "i", i, "n", n) } if C.dpiVar_setNumElementsInArray(dv, C.uint32_t(n)) == C.DPI_FAILURE { - return errors.Wrapf(st.getError(), "%+v.setNumElementsInArray[%d](%d)", dv, i, n) + return errors.Errorf("%+v.setNumElementsInArray[%d](%d): %w", dv, i, n, st.getError()) } } //fmt.Println("n:", len(st.data[i])) @@ -796,7 +823,7 @@ func (st *statement) bindVars(args []driver.NamedValue, Log logFunc) error { for i, v := range st.vars { //if Log != nil {Log("C", "dpiStmt_bindByPos", "dpiStmt", st.dpiStmt, "i", i, "v", v) } if C.dpiStmt_bindByPos(st.dpiStmt, C.uint32_t(i+1), v) == C.DPI_FAILURE { - return errors.Wrapf(st.getError(), "bindByPos[%d]", i) + return errors.Errorf("bindByPos[%d]: %w", i, st.getError()) } } return nil @@ -811,7 +838,7 @@ func (st *statement) bindVars(args []driver.NamedValue, Log logFunc) error { res := C.dpiStmt_bindByName(st.dpiStmt, cName, C.uint32_t(len(name)), st.vars[i]) C.free(unsafe.Pointer(cName)) if res == C.DPI_FAILURE { - return errors.Wrapf(st.getError(), "bindByName[%q]", name) + return errors.Errorf("bindByName[%q]: %w", name, st.getError()) } } return nil @@ -835,7 +862,7 @@ func (st *statement) bindVarTypeSwitch(info *argInfo, get *dataGetter, value int if isValuer { var err error if value, err = vlr.Value(); err != nil { - return value, errors.Wrap(err, "arg.Value()") + return value, errors.Errorf("arg.Value(): %w", err) } return st.bindVarTypeSwitch(info, get, value) } @@ -1017,7 +1044,7 @@ func (st *statement) bindVarTypeSwitch(info *argInfo, get *dataGetter, value int } info.set = dataSetBytes if info.isOut { - info.bufSize = 4000 + info.bufSize = 32767 *get = dataGetBytes } @@ -1073,8 +1100,10 @@ func (st *statement) bindVarTypeSwitch(info *argInfo, get *dataGetter, value int } case *Object: - info.objType = v.ObjectType.dpiObjectType - info.typ, info.natTyp = C.DPI_ORACLE_TYPE_OBJECT, C.DPI_NATIVE_TYPE_OBJECT + if !nilPtr && v != nil { + info.objType = v.ObjectType.dpiObjectType + info.typ, info.natTyp = C.DPI_ORACLE_TYPE_OBJECT, C.DPI_NATIVE_TYPE_OBJECT + } info.set = st.dataSetObject if info.isOut { *get = st.dataGetObject @@ -1094,7 +1123,7 @@ func (st *statement) bindVarTypeSwitch(info *argInfo, get *dataGetter, value int } var err error if value, err = vlr.Value(); err != nil { - return value, errors.Wrap(err, "arg.Value()") + return value, errors.Errorf("arg.Value(): %w", err) } return st.bindVarTypeSwitch(info, get, value) } @@ -1139,6 +1168,13 @@ func dataSetBool(dv *C.dpiVar, data []C.dpiData, vv interface{}) error { return dataSetNull(dv, data, nil) } b := C.int(0) + if v, ok := vv.(bool); ok { + if v { + b = 1 + } + C.dpiData_setBool(&data[0], b) + return nil + } if bb, ok := vv.([]bool); ok { for i, v := range bb { if v { @@ -1146,10 +1182,10 @@ func dataSetBool(dv *C.dpiVar, data []C.dpiData, vv interface{}) error { } C.dpiData_setBool(&data[i], b) } - } else { - for i := range data { - data[i].isNull = 1 - } + return nil + } + for i := range data { + data[i].isNull = 1 } return nil } @@ -1507,18 +1543,27 @@ func dataGetBytes(v interface{}, data []C.dpiData) error { *x = nil return nil } - b := C.dpiData_getBytes(&data[0]) + db := C.dpiData_getBytes(&data[0]) + b := ((*[32767]byte)(unsafe.Pointer(db.ptr)))[:db.length:db.length] + // b must be copied + *x = append((*x)[:0], b...) - *x = ((*[32767]byte)(unsafe.Pointer(b.ptr)))[:b.length:b.length] case *[][]byte: + maX := (*x)[:cap(*x)] *x = (*x)[:0] for i := range data { if data[i].isNull == 1 { *x = append(*x, nil) continue } - b := C.dpiData_getBytes(&data[i]) - *x = append(*x, ((*[32767]byte)(unsafe.Pointer(b.ptr)))[:b.length:b.length]) + db := C.dpiData_getBytes(&data[i]) + b := ((*[32767]byte)(unsafe.Pointer(db.ptr)))[:db.length:db.length] + // b must be copied + if i < len(maX) { + *x = append(*x, append(maX[i][:0], b...)) + } else { + *x = append(*x, append(make([]byte, 0, len(b)), b...)) + } } case *Number: @@ -1702,7 +1747,7 @@ func (c *conn) dataGetStmtC(row *driver.Rows, data *C.dpiData) error { var n C.uint32_t if C.dpiStmt_getNumQueryColumns(st.dpiStmt, &n) == C.DPI_FAILURE { *row = &rows{ - err: errors.Wrapf(io.EOF, "getNumQueryColumns: %v", c.getError()), + err: errors.Errorf("getNumQueryColumns: %w: %w", c.getError(), io.EOF), } return nil } @@ -1777,7 +1822,7 @@ func (c *conn) dataSetLOB(dv *C.dpiVar, data []C.dpiData, vv interface{}) error } var lob *C.dpiLob if C.dpiConn_newTempLob(c.dpiConn, typ, &lob) == C.DPI_FAILURE { - return errors.Wrapf(c.getError(), "newTempLob(typ=%d)", typ) + return errors.Errorf("newTempLob(typ=%d): %w", typ, c.getError()) } var chunkSize C.uint32_t _ = C.dpiLob_getChunkSize(lob, &chunkSize) @@ -1832,8 +1877,15 @@ func (c *conn) dataSetObject(dv *C.dpiVar, data []C.dpiData, vv interface{}) err switch o := vv.(type) { case Object: objs[0] = o + case *Object: + objs[0] = *o case []Object: objs = o + case []*Object: + objs = make([]Object, len(o)) + for i, x := range o { + objs[i] = *x + } case ObjectWriter: err := o.WriteObject() if err != nil { @@ -1858,10 +1910,12 @@ func (c *conn) dataSetObject(dv *C.dpiVar, data []C.dpiData, vv interface{}) err for i, obj := range objs { if obj.dpiObject == nil { data[i].isNull = 1 - return nil + continue } data[i].isNull = 0 - C.dpiVar_setFromObject(dv, C.uint32_t(i), obj.dpiObject) + if C.dpiVar_setFromObject(dv, C.uint32_t(i), obj.dpiObject) == C.DPI_FAILURE { + return errors.Errorf("setFromObject: %w", c.getError()) + } } return nil } @@ -1871,13 +1925,13 @@ func (c *conn) dataGetObject(v interface{}, data []C.dpiData) error { case *Object: d := Data{ ObjectType: out.ObjectType, - dpiData: &data[0], + dpiData: data[0], } *out = *d.GetObject() case ObjectScanner: d := Data{ ObjectType: out.ObjectRef().ObjectType, - dpiData: &data[0], + dpiData: data[0], } return out.Scan(d.GetObject()) default: @@ -1949,7 +2003,7 @@ func (st *statement) openRows(colCount int) (*rows, error) { var ti C.dpiDataTypeInfo for i := 0; i < colCount; i++ { if C.dpiStmt_getQueryInfo(st.dpiStmt, C.uint32_t(i+1), &info) == C.DPI_FAILURE { - return nil, errors.Wrapf(st.getError(), "getQueryInfo[%d]", i) + return nil, errors.Errorf("getQueryInfo[%d]: %w", i, st.getError()) } ti = info.typeInfo bufSize := int(ti.clientSizeInBytes) @@ -2002,11 +2056,11 @@ func (st *statement) openRows(colCount int) (*rows, error) { } if C.dpiStmt_define(st.dpiStmt, C.uint32_t(i+1), r.vars[i]) == C.DPI_FAILURE { - return nil, errors.Wrapf(st.getError(), "define[%d]", i) + return nil, errors.Errorf("define[%d]: %w", i, st.getError()) } } if C.dpiStmt_addRef(st.dpiStmt) == C.DPI_FAILURE { - return &r, errors.Wrap(st.getError(), "dpiStmt_addRef") + return &r, errors.Errorf("dpiStmt_addRef: %w", st.getError()) } st.columns = r.columns return &r, nil @@ -2023,3 +2077,41 @@ type Column struct { Scale C.int8_t Nullable bool } + +func dpiSetFromString(dv *C.dpiVar, pos C.uint32_t, x string) { + C.godror_setFromString(dv, pos, x) +} + +var stringBuilders = stringBuilderPool{ + p: &sync.Pool{New: func() interface{} { return &strings.Builder{} }}, +} + +type stringBuilderPool struct { + p *sync.Pool +} + +func (sb stringBuilderPool) Get() *strings.Builder { + return sb.p.Get().(*strings.Builder) +} +func (sb *stringBuilderPool) Put(b *strings.Builder) { + b.Reset() + sb.p.Put(b) +} + +/* +// ResetSession is called while a connection is in the connection +// pool. No queries will run on this connection until this method returns. +// +// If the connection is bad this should return driver.ErrBadConn to prevent +// the connection from being returned to the connection pool. Any other +// error will be discarded. +func (c *conn) ResetSession(ctx context.Context) error { + if Log != nil { + Log("msg", "ResetSession", "conn", c.dpiConn) + } + //subCtx, cancel := context.WithTimeout(ctx, 30*time.Second) + //err := c.Ping(subCtx) + //cancel() + return c.Ping(ctx) +} +*/ diff --git a/vendor/gopkg.in/goracle.v2/subscr.c b/vendor/github.com/godror/godror/subscr.c similarity index 100% rename from vendor/gopkg.in/goracle.v2/subscr.c rename to vendor/github.com/godror/godror/subscr.c diff --git a/vendor/gopkg.in/goracle.v2/subscr.go b/vendor/github.com/godror/godror/subscr.go similarity index 83% rename from vendor/gopkg.in/goracle.v2/subscr.go rename to vendor/github.com/godror/godror/subscr.go index 6286ec10c84..872f7ee6969 100644 --- a/vendor/gopkg.in/goracle.v2/subscr.go +++ b/vendor/github.com/godror/godror/subscr.go @@ -1,19 +1,9 @@ // Copyright 2017 Tamás Gulácsi // // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-License-Identifier: UPL-1.0 OR Apache-2.0 -package goracle +package godror /* #include @@ -28,9 +18,17 @@ import "C" import ( "log" "strings" + "sync" "unsafe" - "github.com/pkg/errors" + errors "golang.org/x/xerrors" +) + +// Cannot pass *Subscription to C, so pass an uint64 that points to this map entry +var ( + subscriptionsMu sync.Mutex + subscriptions = make(map[uint64]*Subscription) + subscriptionsID uint64 ) // CallbackSubscr is the callback for C code on subscription event. @@ -40,7 +38,9 @@ func CallbackSubscr(ctx unsafe.Pointer, message *C.dpiSubscrMessage) { if ctx == nil { return } - subscr := (*Subscription)(ctx) + subscriptionsMu.Lock() + subscr := subscriptions[*((*uint64)(ctx))] + subscriptionsMu.Unlock() getRows := func(rws *C.dpiSubscrMessageRow, rwsNum C.uint32_t) []RowEvent { if rwsNum == 0 { @@ -134,6 +134,7 @@ type Subscription struct { conn *conn dpiSubscr *C.dpiSubscr callback func(Event) + ID uint64 } func (s *Subscription) getError() error { return s.conn.getError() } @@ -150,7 +151,7 @@ func (c *conn) NewSubscription(name string, cb func(Event)) (*Subscription, erro subscr := Subscription{conn: c, callback: cb} params := (*C.dpiSubscrCreateParams)(C.malloc(C.sizeof_dpiSubscrCreateParams)) //defer func() { C.free(unsafe.Pointer(params)) }() - C.dpiContext_initSubscrCreateParams(c.dpiContext, params) + C.dpiContext_initSubscrCreateParams(c.drv.dpiContext, params) params.subscrNamespace = C.DPI_SUBSCR_NAMESPACE_DBCHANGE params.protocol = C.DPI_SUBSCR_PROTO_CALLBACK params.qos = C.DPI_SUBSCR_QOS_BEST_EFFORT | C.DPI_SUBSCR_QOS_QUERY | C.DPI_SUBSCR_QOS_ROWIDS @@ -161,7 +162,15 @@ func (c *conn) NewSubscription(name string, cb func(Event)) (*Subscription, erro } // typedef void (*dpiSubscrCallback)(void* context, dpiSubscrMessage *message); params.callback = C.dpiSubscrCallback(C.CallbackSubscrDebug) - params.callbackContext = unsafe.Pointer(&subscr) + // cannot pass &subscr to C, so pass indirectly + subscriptionsMu.Lock() + subscriptionsID++ + subscr.ID = subscriptionsID + subscriptions[subscr.ID] = &subscr + subscriptionsMu.Unlock() + subscrID := (*C.uint64_t)(C.malloc(8)) + *subscrID = C.uint64_t(subscriptionsID) + params.callbackContext = unsafe.Pointer(subscrID) dpiSubscr := (*C.dpiSubscr)(C.malloc(C.sizeof_void)) @@ -171,9 +180,9 @@ func (c *conn) NewSubscription(name string, cb func(Event)) (*Subscription, erro ) == C.DPI_FAILURE { C.free(unsafe.Pointer(params)) C.free(unsafe.Pointer(dpiSubscr)) - err := errors.Wrap(c.getError(), "newSubscription") - if strings.Contains(errors.Cause(err).Error(), "DPI-1065:") { - err = errors.WithMessage(err, "specify \"enableEvents=1\" connection parameter on connection to be able to use subscriptions") + err := errors.Errorf("newSubscription: %w", c.getError()) + if strings.Contains(errors.Unwrap(err).Error(), "DPI-1065:") { + err = errors.Errorf("specify \"enableEvents=1\" connection parameter on connection to be able to use subscriptions: %w", err) } return nil, err } @@ -190,18 +199,18 @@ func (s *Subscription) Register(qry string, params ...interface{}) error { var dpiStmt *C.dpiStmt if C.dpiSubscr_prepareStmt(s.dpiSubscr, cQry, C.uint32_t(len(qry)), &dpiStmt) == C.DPI_FAILURE { - return errors.Wrapf(s.getError(), "prepareStmt[%p]", s.dpiSubscr) + return errors.Errorf("prepareStmt[%p]: %w", s.dpiSubscr, s.getError()) } defer func() { C.dpiStmt_release(dpiStmt) }() mode := C.dpiExecMode(C.DPI_MODE_EXEC_DEFAULT) var qCols C.uint32_t if C.dpiStmt_execute(dpiStmt, mode, &qCols) == C.DPI_FAILURE { - return errors.Wrap(s.getError(), "executeStmt") + return errors.Errorf("executeStmt: %w", s.getError()) } var queryID C.uint64_t if C.dpiStmt_getSubscrQueryId(dpiStmt, &queryID) == C.DPI_FAILURE { - return errors.Wrap(s.getError(), "getSubscrQueryId") + return errors.Errorf("getSubscrQueryId: %w", s.getError()) } if Log != nil { Log("msg", "subscribed", "query", qry, "id", queryID) @@ -214,6 +223,9 @@ func (s *Subscription) Register(qry string, params ...interface{}) error { // // This code is EXPERIMENTAL yet! func (s *Subscription) Close() error { + subscriptionsMu.Lock() + delete(subscriptions, s.ID) + subscriptionsMu.Unlock() dpiSubscr := s.dpiSubscr conn := s.conn s.conn = nil @@ -223,7 +235,7 @@ func (s *Subscription) Close() error { return nil } if C.dpiConn_unsubscribe(conn.dpiConn, dpiSubscr) == C.DPI_FAILURE { - return errors.Wrap(s.getError(), "close") + return errors.Errorf("close: %w", s.getError()) } return nil } @@ -236,10 +248,10 @@ const ( EvtStartup = EventType(C.DPI_EVENT_STARTUP) EvtShutdown = EventType(C.DPI_EVENT_SHUTDOWN) EvtShutdownAny = EventType(C.DPI_EVENT_SHUTDOWN_ANY) - EvtDropDB = EventType(C.DPI_EVENT_DROP_DB) EvtDereg = EventType(C.DPI_EVENT_DEREG) EvtObjChange = EventType(C.DPI_EVENT_OBJCHANGE) EvtQueryChange = EventType(C.DPI_EVENT_QUERYCHANGE) + EvtAQ = EventType(C.DPI_EVENT_AQ) ) // Operation in the DB. diff --git a/vendor/gopkg.in/goracle.v2/version.go b/vendor/github.com/godror/godror/version.go similarity index 57% rename from vendor/gopkg.in/goracle.v2/version.go rename to vendor/github.com/godror/godror/version.go index 111b3462741..66059da1141 100644 --- a/vendor/gopkg.in/goracle.v2/version.go +++ b/vendor/github.com/godror/godror/version.go @@ -1,6 +1,10 @@ -package goracle +// Copyright 2020 Tamás Gulácsi. +// +// SPDX-License-Identifier: UPL-1.0 OR Apache-2.0 -//go:generate bash -c "echo 3.1.4>odpi-version; set -x; curl -L https://github.com/oracle/odpi/archive/v$(cat odpi-version).tar.gz | tar xzvf - odpi-$(cat odpi-version)/{embed,include,src,CONTRIBUTING.md,LICENSE.md,README.md} && rm -rf odpi && mv odpi-$(cat odpi-version) odpi; rm -f odpi-version" +package godror + +//go:generate bash -c "echo 3.3.0>odpi-version; set -x; curl -L https://github.com/oracle/odpi/archive/v$(cat odpi-version).tar.gz | tar xzvf - odpi-$(cat odpi-version)/{embed,include,src,CONTRIBUTING.md,LICENSE.md,README.md} && rm -rf odpi && mv odpi-$(cat odpi-version) odpi; rm -f odpi-version" // Version of this driver -const Version = "v2.15.3" +const Version = "v0.10.4" diff --git a/vendor/golang.org/x/xerrors/LICENSE b/vendor/golang.org/x/xerrors/LICENSE new file mode 100644 index 00000000000..e4a47e17f14 --- /dev/null +++ b/vendor/golang.org/x/xerrors/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2019 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/golang.org/x/xerrors/PATENTS b/vendor/golang.org/x/xerrors/PATENTS new file mode 100644 index 00000000000..733099041f8 --- /dev/null +++ b/vendor/golang.org/x/xerrors/PATENTS @@ -0,0 +1,22 @@ +Additional IP Rights Grant (Patents) + +"This implementation" means the copyrightable works distributed by +Google as part of the Go project. + +Google hereby grants to You a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable (except as stated in this section) +patent license to make, have made, use, offer to sell, sell, import, +transfer and otherwise run, modify and propagate the contents of this +implementation of Go, where such license applies only to those patent +claims, both currently owned or controlled by Google and acquired in +the future, licensable by Google that are necessarily infringed by this +implementation of Go. This grant does not include claims that would be +infringed only as a consequence of further modification of this +implementation. If you or your agent or exclusive licensee institute or +order or agree to the institution of patent litigation against any +entity (including a cross-claim or counterclaim in a lawsuit) alleging +that this implementation of Go or any code incorporated within this +implementation of Go constitutes direct or contributory patent +infringement, or inducement of patent infringement, then any patent +rights granted to you under this License for this implementation of Go +shall terminate as of the date such litigation is filed. diff --git a/vendor/golang.org/x/xerrors/README b/vendor/golang.org/x/xerrors/README new file mode 100644 index 00000000000..aac7867a560 --- /dev/null +++ b/vendor/golang.org/x/xerrors/README @@ -0,0 +1,2 @@ +This repository holds the transition packages for the new Go 1.13 error values. +See golang.org/design/29934-error-values. diff --git a/vendor/golang.org/x/xerrors/adaptor.go b/vendor/golang.org/x/xerrors/adaptor.go new file mode 100644 index 00000000000..4317f248331 --- /dev/null +++ b/vendor/golang.org/x/xerrors/adaptor.go @@ -0,0 +1,193 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package xerrors + +import ( + "bytes" + "fmt" + "io" + "reflect" + "strconv" +) + +// FormatError calls the FormatError method of f with an errors.Printer +// configured according to s and verb, and writes the result to s. +func FormatError(f Formatter, s fmt.State, verb rune) { + // Assuming this function is only called from the Format method, and given + // that FormatError takes precedence over Format, it cannot be called from + // any package that supports errors.Formatter. It is therefore safe to + // disregard that State may be a specific printer implementation and use one + // of our choice instead. + + // limitations: does not support printing error as Go struct. + + var ( + sep = " " // separator before next error + p = &state{State: s} + direct = true + ) + + var err error = f + + switch verb { + // Note that this switch must match the preference order + // for ordinary string printing (%#v before %+v, and so on). + + case 'v': + if s.Flag('#') { + if stringer, ok := err.(fmt.GoStringer); ok { + io.WriteString(&p.buf, stringer.GoString()) + goto exit + } + // proceed as if it were %v + } else if s.Flag('+') { + p.printDetail = true + sep = "\n - " + } + case 's': + case 'q', 'x', 'X': + // Use an intermediate buffer in the rare cases that precision, + // truncation, or one of the alternative verbs (q, x, and X) are + // specified. + direct = false + + default: + p.buf.WriteString("%!") + p.buf.WriteRune(verb) + p.buf.WriteByte('(') + switch { + case err != nil: + p.buf.WriteString(reflect.TypeOf(f).String()) + default: + p.buf.WriteString("") + } + p.buf.WriteByte(')') + io.Copy(s, &p.buf) + return + } + +loop: + for { + switch v := err.(type) { + case Formatter: + err = v.FormatError((*printer)(p)) + case fmt.Formatter: + v.Format(p, 'v') + break loop + default: + io.WriteString(&p.buf, v.Error()) + break loop + } + if err == nil { + break + } + if p.needColon || !p.printDetail { + p.buf.WriteByte(':') + p.needColon = false + } + p.buf.WriteString(sep) + p.inDetail = false + p.needNewline = false + } + +exit: + width, okW := s.Width() + prec, okP := s.Precision() + + if !direct || (okW && width > 0) || okP { + // Construct format string from State s. + format := []byte{'%'} + if s.Flag('-') { + format = append(format, '-') + } + if s.Flag('+') { + format = append(format, '+') + } + if s.Flag(' ') { + format = append(format, ' ') + } + if okW { + format = strconv.AppendInt(format, int64(width), 10) + } + if okP { + format = append(format, '.') + format = strconv.AppendInt(format, int64(prec), 10) + } + format = append(format, string(verb)...) + fmt.Fprintf(s, string(format), p.buf.String()) + } else { + io.Copy(s, &p.buf) + } +} + +var detailSep = []byte("\n ") + +// state tracks error printing state. It implements fmt.State. +type state struct { + fmt.State + buf bytes.Buffer + + printDetail bool + inDetail bool + needColon bool + needNewline bool +} + +func (s *state) Write(b []byte) (n int, err error) { + if s.printDetail { + if len(b) == 0 { + return 0, nil + } + if s.inDetail && s.needColon { + s.needNewline = true + if b[0] == '\n' { + b = b[1:] + } + } + k := 0 + for i, c := range b { + if s.needNewline { + if s.inDetail && s.needColon { + s.buf.WriteByte(':') + s.needColon = false + } + s.buf.Write(detailSep) + s.needNewline = false + } + if c == '\n' { + s.buf.Write(b[k:i]) + k = i + 1 + s.needNewline = true + } + } + s.buf.Write(b[k:]) + if !s.inDetail { + s.needColon = true + } + } else if !s.inDetail { + s.buf.Write(b) + } + return len(b), nil +} + +// printer wraps a state to implement an xerrors.Printer. +type printer state + +func (s *printer) Print(args ...interface{}) { + if !s.inDetail || s.printDetail { + fmt.Fprint((*state)(s), args...) + } +} + +func (s *printer) Printf(format string, args ...interface{}) { + if !s.inDetail || s.printDetail { + fmt.Fprintf((*state)(s), format, args...) + } +} + +func (s *printer) Detail() bool { + s.inDetail = true + return s.printDetail +} diff --git a/vendor/golang.org/x/xerrors/codereview.cfg b/vendor/golang.org/x/xerrors/codereview.cfg new file mode 100644 index 00000000000..3f8b14b64e8 --- /dev/null +++ b/vendor/golang.org/x/xerrors/codereview.cfg @@ -0,0 +1 @@ +issuerepo: golang/go diff --git a/vendor/golang.org/x/xerrors/doc.go b/vendor/golang.org/x/xerrors/doc.go new file mode 100644 index 00000000000..eef99d9d54d --- /dev/null +++ b/vendor/golang.org/x/xerrors/doc.go @@ -0,0 +1,22 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package xerrors implements functions to manipulate errors. +// +// This package is based on the Go 2 proposal for error values: +// https://golang.org/design/29934-error-values +// +// These functions were incorporated into the standard library's errors package +// in Go 1.13: +// - Is +// - As +// - Unwrap +// +// Also, Errorf's %w verb was incorporated into fmt.Errorf. +// +// Use this package to get equivalent behavior in all supported Go versions. +// +// No other features of this package were included in Go 1.13, and at present +// there are no plans to include any of them. +package xerrors // import "golang.org/x/xerrors" diff --git a/vendor/golang.org/x/xerrors/errors.go b/vendor/golang.org/x/xerrors/errors.go new file mode 100644 index 00000000000..e88d3772d86 --- /dev/null +++ b/vendor/golang.org/x/xerrors/errors.go @@ -0,0 +1,33 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package xerrors + +import "fmt" + +// errorString is a trivial implementation of error. +type errorString struct { + s string + frame Frame +} + +// New returns an error that formats as the given text. +// +// The returned error contains a Frame set to the caller's location and +// implements Formatter to show this information when printed with details. +func New(text string) error { + return &errorString{text, Caller(1)} +} + +func (e *errorString) Error() string { + return e.s +} + +func (e *errorString) Format(s fmt.State, v rune) { FormatError(e, s, v) } + +func (e *errorString) FormatError(p Printer) (next error) { + p.Print(e.s) + e.frame.Format(p) + return nil +} diff --git a/vendor/golang.org/x/xerrors/fmt.go b/vendor/golang.org/x/xerrors/fmt.go new file mode 100644 index 00000000000..829862ddf6a --- /dev/null +++ b/vendor/golang.org/x/xerrors/fmt.go @@ -0,0 +1,187 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package xerrors + +import ( + "fmt" + "strings" + "unicode" + "unicode/utf8" + + "golang.org/x/xerrors/internal" +) + +const percentBangString = "%!" + +// Errorf formats according to a format specifier and returns the string as a +// value that satisfies error. +// +// The returned error includes the file and line number of the caller when +// formatted with additional detail enabled. If the last argument is an error +// the returned error's Format method will return it if the format string ends +// with ": %s", ": %v", or ": %w". If the last argument is an error and the +// format string ends with ": %w", the returned error implements an Unwrap +// method returning it. +// +// If the format specifier includes a %w verb with an error operand in a +// position other than at the end, the returned error will still implement an +// Unwrap method returning the operand, but the error's Format method will not +// return the wrapped error. +// +// It is invalid to include more than one %w verb or to supply it with an +// operand that does not implement the error interface. The %w verb is otherwise +// a synonym for %v. +func Errorf(format string, a ...interface{}) error { + format = formatPlusW(format) + // Support a ": %[wsv]" suffix, which works well with xerrors.Formatter. + wrap := strings.HasSuffix(format, ": %w") + idx, format2, ok := parsePercentW(format) + percentWElsewhere := !wrap && idx >= 0 + if !percentWElsewhere && (wrap || strings.HasSuffix(format, ": %s") || strings.HasSuffix(format, ": %v")) { + err := errorAt(a, len(a)-1) + if err == nil { + return &noWrapError{fmt.Sprintf(format, a...), nil, Caller(1)} + } + // TODO: this is not entirely correct. The error value could be + // printed elsewhere in format if it mixes numbered with unnumbered + // substitutions. With relatively small changes to doPrintf we can + // have it optionally ignore extra arguments and pass the argument + // list in its entirety. + msg := fmt.Sprintf(format[:len(format)-len(": %s")], a[:len(a)-1]...) + frame := Frame{} + if internal.EnableTrace { + frame = Caller(1) + } + if wrap { + return &wrapError{msg, err, frame} + } + return &noWrapError{msg, err, frame} + } + // Support %w anywhere. + // TODO: don't repeat the wrapped error's message when %w occurs in the middle. + msg := fmt.Sprintf(format2, a...) + if idx < 0 { + return &noWrapError{msg, nil, Caller(1)} + } + err := errorAt(a, idx) + if !ok || err == nil { + // Too many %ws or argument of %w is not an error. Approximate the Go + // 1.13 fmt.Errorf message. + return &noWrapError{fmt.Sprintf("%sw(%s)", percentBangString, msg), nil, Caller(1)} + } + frame := Frame{} + if internal.EnableTrace { + frame = Caller(1) + } + return &wrapError{msg, err, frame} +} + +func errorAt(args []interface{}, i int) error { + if i < 0 || i >= len(args) { + return nil + } + err, ok := args[i].(error) + if !ok { + return nil + } + return err +} + +// formatPlusW is used to avoid the vet check that will barf at %w. +func formatPlusW(s string) string { + return s +} + +// Return the index of the only %w in format, or -1 if none. +// Also return a rewritten format string with %w replaced by %v, and +// false if there is more than one %w. +// TODO: handle "%[N]w". +func parsePercentW(format string) (idx int, newFormat string, ok bool) { + // Loosely copied from golang.org/x/tools/go/analysis/passes/printf/printf.go. + idx = -1 + ok = true + n := 0 + sz := 0 + var isW bool + for i := 0; i < len(format); i += sz { + if format[i] != '%' { + sz = 1 + continue + } + // "%%" is not a format directive. + if i+1 < len(format) && format[i+1] == '%' { + sz = 2 + continue + } + sz, isW = parsePrintfVerb(format[i:]) + if isW { + if idx >= 0 { + ok = false + } else { + idx = n + } + // "Replace" the last character, the 'w', with a 'v'. + p := i + sz - 1 + format = format[:p] + "v" + format[p+1:] + } + n++ + } + return idx, format, ok +} + +// Parse the printf verb starting with a % at s[0]. +// Return how many bytes it occupies and whether the verb is 'w'. +func parsePrintfVerb(s string) (int, bool) { + // Assume only that the directive is a sequence of non-letters followed by a single letter. + sz := 0 + var r rune + for i := 1; i < len(s); i += sz { + r, sz = utf8.DecodeRuneInString(s[i:]) + if unicode.IsLetter(r) { + return i + sz, r == 'w' + } + } + return len(s), false +} + +type noWrapError struct { + msg string + err error + frame Frame +} + +func (e *noWrapError) Error() string { + return fmt.Sprint(e) +} + +func (e *noWrapError) Format(s fmt.State, v rune) { FormatError(e, s, v) } + +func (e *noWrapError) FormatError(p Printer) (next error) { + p.Print(e.msg) + e.frame.Format(p) + return e.err +} + +type wrapError struct { + msg string + err error + frame Frame +} + +func (e *wrapError) Error() string { + return fmt.Sprint(e) +} + +func (e *wrapError) Format(s fmt.State, v rune) { FormatError(e, s, v) } + +func (e *wrapError) FormatError(p Printer) (next error) { + p.Print(e.msg) + e.frame.Format(p) + return e.err +} + +func (e *wrapError) Unwrap() error { + return e.err +} diff --git a/vendor/golang.org/x/xerrors/format.go b/vendor/golang.org/x/xerrors/format.go new file mode 100644 index 00000000000..1bc9c26b97f --- /dev/null +++ b/vendor/golang.org/x/xerrors/format.go @@ -0,0 +1,34 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package xerrors + +// A Formatter formats error messages. +type Formatter interface { + error + + // FormatError prints the receiver's first error and returns the next error in + // the error chain, if any. + FormatError(p Printer) (next error) +} + +// A Printer formats error messages. +// +// The most common implementation of Printer is the one provided by package fmt +// during Printf (as of Go 1.13). Localization packages such as golang.org/x/text/message +// typically provide their own implementations. +type Printer interface { + // Print appends args to the message output. + Print(args ...interface{}) + + // Printf writes a formatted string. + Printf(format string, args ...interface{}) + + // Detail reports whether error detail is requested. + // After the first call to Detail, all text written to the Printer + // is formatted as additional detail, or ignored when + // detail has not been requested. + // If Detail returns false, the caller can avoid printing the detail at all. + Detail() bool +} diff --git a/vendor/golang.org/x/xerrors/frame.go b/vendor/golang.org/x/xerrors/frame.go new file mode 100644 index 00000000000..0de628ec501 --- /dev/null +++ b/vendor/golang.org/x/xerrors/frame.go @@ -0,0 +1,56 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package xerrors + +import ( + "runtime" +) + +// A Frame contains part of a call stack. +type Frame struct { + // Make room for three PCs: the one we were asked for, what it called, + // and possibly a PC for skipPleaseUseCallersFrames. See: + // https://go.googlesource.com/go/+/032678e0fb/src/runtime/extern.go#169 + frames [3]uintptr +} + +// Caller returns a Frame that describes a frame on the caller's stack. +// The argument skip is the number of frames to skip over. +// Caller(0) returns the frame for the caller of Caller. +func Caller(skip int) Frame { + var s Frame + runtime.Callers(skip+1, s.frames[:]) + return s +} + +// location reports the file, line, and function of a frame. +// +// The returned function may be "" even if file and line are not. +func (f Frame) location() (function, file string, line int) { + frames := runtime.CallersFrames(f.frames[:]) + if _, ok := frames.Next(); !ok { + return "", "", 0 + } + fr, ok := frames.Next() + if !ok { + return "", "", 0 + } + return fr.Function, fr.File, fr.Line +} + +// Format prints the stack as error detail. +// It should be called from an error's Format implementation +// after printing any other error detail. +func (f Frame) Format(p Printer) { + if p.Detail() { + function, file, line := f.location() + if function != "" { + p.Printf("%s\n ", function) + } + if file != "" { + p.Printf("%s:%d\n", file, line) + } + } +} diff --git a/vendor/golang.org/x/xerrors/go.mod b/vendor/golang.org/x/xerrors/go.mod new file mode 100644 index 00000000000..870d4f612db --- /dev/null +++ b/vendor/golang.org/x/xerrors/go.mod @@ -0,0 +1,3 @@ +module golang.org/x/xerrors + +go 1.11 diff --git a/vendor/golang.org/x/xerrors/internal/internal.go b/vendor/golang.org/x/xerrors/internal/internal.go new file mode 100644 index 00000000000..89f4eca5df7 --- /dev/null +++ b/vendor/golang.org/x/xerrors/internal/internal.go @@ -0,0 +1,8 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package internal + +// EnableTrace indicates whether stack information should be recorded in errors. +var EnableTrace = true diff --git a/vendor/golang.org/x/xerrors/wrap.go b/vendor/golang.org/x/xerrors/wrap.go new file mode 100644 index 00000000000..9a3b510374e --- /dev/null +++ b/vendor/golang.org/x/xerrors/wrap.go @@ -0,0 +1,106 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package xerrors + +import ( + "reflect" +) + +// A Wrapper provides context around another error. +type Wrapper interface { + // Unwrap returns the next error in the error chain. + // If there is no next error, Unwrap returns nil. + Unwrap() error +} + +// Opaque returns an error with the same error formatting as err +// but that does not match err and cannot be unwrapped. +func Opaque(err error) error { + return noWrapper{err} +} + +type noWrapper struct { + error +} + +func (e noWrapper) FormatError(p Printer) (next error) { + if f, ok := e.error.(Formatter); ok { + return f.FormatError(p) + } + p.Print(e.error) + return nil +} + +// Unwrap returns the result of calling the Unwrap method on err, if err implements +// Unwrap. Otherwise, Unwrap returns nil. +func Unwrap(err error) error { + u, ok := err.(Wrapper) + if !ok { + return nil + } + return u.Unwrap() +} + +// Is reports whether any error in err's chain matches target. +// +// An error is considered to match a target if it is equal to that target or if +// it implements a method Is(error) bool such that Is(target) returns true. +func Is(err, target error) bool { + if target == nil { + return err == target + } + + isComparable := reflect.TypeOf(target).Comparable() + for { + if isComparable && err == target { + return true + } + if x, ok := err.(interface{ Is(error) bool }); ok && x.Is(target) { + return true + } + // TODO: consider supporing target.Is(err). This would allow + // user-definable predicates, but also may allow for coping with sloppy + // APIs, thereby making it easier to get away with them. + if err = Unwrap(err); err == nil { + return false + } + } +} + +// As finds the first error in err's chain that matches the type to which target +// points, and if so, sets the target to its value and returns true. An error +// matches a type if it is assignable to the target type, or if it has a method +// As(interface{}) bool such that As(target) returns true. As will panic if target +// is not a non-nil pointer to a type which implements error or is of interface type. +// +// The As method should set the target to its value and return true if err +// matches the type to which target points. +func As(err error, target interface{}) bool { + if target == nil { + panic("errors: target cannot be nil") + } + val := reflect.ValueOf(target) + typ := val.Type() + if typ.Kind() != reflect.Ptr || val.IsNil() { + panic("errors: target must be a non-nil pointer") + } + if e := typ.Elem(); e.Kind() != reflect.Interface && !e.Implements(errorType) { + panic("errors: *target must be interface or implement error") + } + targetType := typ.Elem() + for err != nil { + if reflect.TypeOf(err).AssignableTo(targetType) { + val.Elem().Set(reflect.ValueOf(err)) + return true + } + if x, ok := err.(interface{ As(interface{}) bool }); ok && x.As(target) { + return true + } + err = Unwrap(err) + } + return false +} + +var errorType = reflect.TypeOf((*error)(nil)).Elem() diff --git a/vendor/gopkg.in/goracle.v2/CHANGELOG.md b/vendor/gopkg.in/goracle.v2/CHANGELOG.md deleted file mode 100644 index 7dd02ae08e3..00000000000 --- a/vendor/gopkg.in/goracle.v2/CHANGELOG.md +++ /dev/null @@ -1,216 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) -and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). - -## [Unreleased] - -## [2.15.3] - 2019-05-16 -### Changed -- ParseConnString: reorder logic to allow 'sys/... as sysdba' (without @) - -## [2.15.3] - 2019-05-16 -### Changed -- ParseConnString: reorder logic to allow 'sys/... as sysdba' (without @) - -## [2.15.2] - 2019-05-12 -### Changed -- Use time.Local if it equals with DBTIMEZONE (use DST of time.Local). - -## [2.15.1] - 2019-05-09 -### Changed -- Fix heterogenous pools (broken with 2.14.1) - -## [2.15.0] - 2019-05-09 -### Added -- Implement dataGetObject to access custom user types -- Add ObjectScanner and ObjectWriter interfaces to provide a way to load/update values from/to a struct and database object type. - -## [2.14.2] - 2019-05-07 -### Added -- Cache timezone with the pool and in the conn struct, too. - -## [2.14.1] - 2019-05-07 -- Try to get the serve DBTIMEZONE, if fails use time.Local - -## [2.14.0] - 2019-05-07 -### Changed -- Default to time.Local in DATE types when sending to DB, too. - -## [2.13.2] - 2019-05-07 -### Changed -- Default to time.Local timezone for DATE types. - -## [2.13.1] - 2019-05-06 -### Changed -- Fix 'INTERVAL DAY TO SECOND' NULL case. - -## [2.12.8] - 2019-05-02 -### Added -- NewConnector, NewSessionIniter - -## [2.12.7] - 2019-04-24 -### Changed -- ODPI-C v3.1.4 (rowcount for PL/SQL block) - -## [2.12.6] - 2019-04-12 -### Added -- Allow calling with LOB got from DB, and don't copy it - see #135. - -## [2.12.5] - 2019-04-03 -### Added -- Make it compile under Go 1.9. - -## [2.12.4] - 2019-03-13 -## Added -- Upgrade to ODPI-C v3.1.3 - -## [2.12.3] - 2019-02-20 -### Changed -- Use ODPI-C v3.1.1 -### Added -- Make goracle.drv implement driver.DriverContext with OpenConnector. - -## [2.12.2] - 2019-02-15 -### Changed -- Use ODPI-C v3.1.1 - -## [2.12.0] - 2019-01-21 -### Changed -- Use ODPI-C v3.1.0 - -## [2.11.2] - 2019-01-15 -### Changed -- ISOLATION LEVEL READ COMMITTED (typo) fix. - -## [2.11.1] - 2018-12-13 -### Changed -- Use C.dpiAuthMode, C.dpiStartupMode, C.dpiShutdownMode instead of C.uint - for #129. - -## [2.11.0] - 2018-12-13 -### Changed -- Do not set empty SID from ORACLE_SID/TWO_TASK environment variables, leave it to ODPI. - -### Added -- Allow PRELIM authentication to allow Startup and Shutdown. - -## [2.10.1] - 2018-11-23 -### Changed -- Don't call SET TRANSACTION if not really needed in BeginTx - if the isolation level hasn't changed. - -## [2.10.0] - 2018-11-18 -### Added -- Implement RowsNextResultSet to return implicit result sets set by DBMS_SQL.return. -- Allow using heterogeneous pools with user set with ContextWithUserPassw. - -## [2.9.1] - 2018-11-14 -### Added -- allow RETURNING with empty result set (such as UPDATE). -- Allow SELECT to return object types. - -### Changed -- fixed Number.MarshalJSON (see #112)' - -## [2.9.0] - 2018-10-12 -### Changed -- The default type for BLOB is []byte and for CLOB is a string - no need for ClobAsString() option. - -## [2.8.2] - 2018-10-01 -### Changed -- Fix the driver.Valuer handling, make it the last resort - -## [2.8.1] - 2018-09-27 -### Added -- CallTimeout option to set a per-statement OCI_ATTR_CALL_TIMEOUT. -- Allow login with " AS SYSASM", as requested in #100. - -### Changed -- Hash the password ("SECRET-sasdas=") in ConnectionParams.String(). - -## [2.8.0] - 2018-09-21 -### Added -- WrapRows wraps a driver.Rows (such as a returned cursor from a stored procedure) as an sql.Rows for easier handling. - -### Changed -- Do not allow events by default, make them opt-in with EnableEvents connection parameter - see #98. - -## [2.7.1] - 2018-09-17 -### Changed -- Inherit parent statement's Options for statements returned as sql.Out. - -## [2.7.0] - 2018-09-14 -### Changed -- Update ODPI-C to v3.0.0. - -## [2.6.0] - 2018-08-31 -### Changed -- convert named types to their underlying scalar values - see #96, using MagicTypeConversion() option. - -## [2.5.11] - 2018-08-30 -### Added -- Allow driver.Valuer as Query argument - see #94. - -## [2.5.10] - 2018-08-26 -### Changed -- use sergeymakinen/oracle-instant-client:12.2 docker for tests -- added ODPI-C and other licenses into LICENSE.md -- fill varInfo.ObjectType for better Object support - -## [2.5.9] - 2018-08-03 -### Added -- add CHANGELOG -- check that `len(dest) == len(rows.columns)` in `rows.Next(dest)` - -### Changed -- after a Break, don't release a stmt, that may fail with SIGSEGV - see #84. - -## [2.5.8] - 2018-07-27 -### Changed -- noConnectionPooling option became standaloneConnection - -## [2.5.7] - 2018-07-25 -### Added -- noConnectionPooling option to force not using a session pool - -## [2.5.6] - 2018-07-18 -### Changed -- use ODPI-C v2.4.2 -- remove all logging/printing of passwords - -## [2.5.5] - 2018-07-03 -### Added -- allow *int with nil value to be used as NULL - -## [2.5.4] - 2018-06-29 -### Added -- allow ReadOnly transactions - -## [2.5.3] - 2018-06-29 -### Changed -- decrease maxArraySize to be compilable on 32-bit architectures. - -### Removed -- remove C struct size Printf - -## [2.5.2] - 2018-06-22 -### Changed -- fix liveness check in statement.Close - -## [2.5.1] - 2018-06-15 -### Changed -- sid -> service_name in docs -- travis: 1.10.3 -- less embedding of structs, clearer API docs - -### Added -- support RETURNING from DML -- set timeouts on poolCreateParams - -## [2.5.0] - 2018-05-15 -### Changed -- update ODPI-C to v2.4.0 -- initialize context / load lib only on first Open, to allow import without Oracle Client installed -- use golangci-lint - - diff --git a/vendor/gopkg.in/goracle.v2/contrib/oracle-instant-client/Dockerfile b/vendor/gopkg.in/goracle.v2/contrib/oracle-instant-client/Dockerfile deleted file mode 100644 index dacc43c3afa..00000000000 --- a/vendor/gopkg.in/goracle.v2/contrib/oracle-instant-client/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -FROM ubuntu:16.04 - -LABEL maintainer="sergey@makinen.ru" - -ENV DEBIAN_FRONTEND noninteractive - -ENV ORACLE_INSTANTCLIENT_MAJOR 12.2 -ENV ORACLE_INSTANTCLIENT_VERSION 12.2.0.1.0 -ENV ORACLE /usr/local/oracle -ENV ORACLE_HOME $ORACLE/lib/oracle/$ORACLE_INSTANTCLIENT_MAJOR/client64 -ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:$ORACLE_HOME/lib -ENV C_INCLUDE_PATH $C_INCLUDE_PATH:$ORACLE/include/oracle/$ORACLE_INSTANTCLIENT_MAJOR/client64 - -RUN apt-get update && apt-get install -y libaio1 \ - curl rpm2cpio cpio \ - && mkdir $ORACLE && TMP_DIR="$(mktemp -d)" && cd "$TMP_DIR" \ - && curl -L https://github.com/sergeymakinen/docker-oracle-instant-client/raw/assets/oracle-instantclient$ORACLE_INSTANTCLIENT_MAJOR-basic-$ORACLE_INSTANTCLIENT_VERSION-1.x86_64.rpm -o basic.rpm \ - && rpm2cpio basic.rpm | cpio -i -d -v && cp -r usr/* $ORACLE && rm -rf ./* \ - && ln -s libclntsh.so.12.1 $ORACLE/lib/oracle/$ORACLE_INSTANTCLIENT_MAJOR/client64/lib/libclntsh.so.$ORACLE_INSTANTCLIENT_MAJOR \ - && ln -s libocci.so.12.1 $ORACLE/lib/oracle/$ORACLE_INSTANTCLIENT_MAJOR/client64/lib/libocci.so.$ORACLE_INSTANTCLIENT_MAJOR \ - && curl -L https://github.com/sergeymakinen/docker-oracle-instant-client/raw/assets/oracle-instantclient$ORACLE_INSTANTCLIENT_MAJOR-devel-$ORACLE_INSTANTCLIENT_VERSION-1.x86_64.rpm -o devel.rpm \ - && rpm2cpio devel.rpm | cpio -i -d -v && cp -r usr/* $ORACLE && rm -rf "$TMP_DIR" \ - && echo "$ORACLE_HOME/lib" > /etc/ld.so.conf.d/oracle.conf && chmod o+r /etc/ld.so.conf.d/oracle.conf && ldconfig \ - && rm -rf /var/lib/apt/lists/* && apt-get purge -y --auto-remove curl rpm2cpio cpio diff --git a/vendor/gopkg.in/goracle.v2/data.go b/vendor/gopkg.in/goracle.v2/data.go deleted file mode 100644 index 4feb4308970..00000000000 --- a/vendor/gopkg.in/goracle.v2/data.go +++ /dev/null @@ -1,281 +0,0 @@ -// Copyright 2017 Tamás Gulácsi -// -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package goracle - -/* -#include -#include "dpiImpl.h" -*/ -import "C" -import ( - "database/sql/driver" - "fmt" - "time" - "unsafe" -) - -// Data holds the data to/from Oracle. -type Data struct { - ObjectType ObjectType - dpiData *C.dpiData - NativeTypeNum C.dpiNativeTypeNum -} - -// IsNull returns whether the data is null. -func (d *Data) IsNull() bool { - return d == nil || d.dpiData == nil || d.dpiData.isNull == 1 -} - -// GetBool returns the bool data. -func (d *Data) GetBool() bool { - return !d.IsNull() && C.dpiData_getBool(d.dpiData) == 1 -} - -// SetBool sets the data as bool. -func (d *Data) SetBool(b bool) { - var i C.int - if b { - i = 1 - } - C.dpiData_setBool(d.dpiData, i) -} - -// GetBytes returns the []byte from the data. -func (d *Data) GetBytes() []byte { - if d.IsNull() { - return nil - } - b := C.dpiData_getBytes(d.dpiData) - return ((*[32767]byte)(unsafe.Pointer(b.ptr)))[:b.length:b.length] -} - -// SetBytes set the data as []byte. -func (d *Data) SetBytes(b []byte) { - if b == nil { - d.dpiData.isNull = 1 - return - } - C.dpiData_setBytes(d.dpiData, (*C.char)(unsafe.Pointer(&b[0])), C.uint32_t(len(b))) -} - -// GetFloat32 gets float32 from the data. -func (d *Data) GetFloat32() float32 { - if d.IsNull() { - return 0 - } - return float32(C.dpiData_getFloat(d.dpiData)) -} - -// SetFloat32 sets the data as float32. -func (d *Data) SetFloat32(f float32) { - C.dpiData_setFloat(d.dpiData, C.float(f)) -} - -// GetFloat64 gets float64 from the data. -func (d *Data) GetFloat64() float64 { - //fmt.Println("GetFloat64", d.IsNull(), d) - if d.IsNull() { - return 0 - } - return float64(C.dpiData_getDouble(d.dpiData)) -} - -// SetFloat64 sets the data as float64. -func (d *Data) SetFloat64(f float64) { - C.dpiData_setDouble(d.dpiData, C.double(f)) -} - -// GetInt64 gets int64 from the data. -func (d *Data) GetInt64() int64 { - if d.IsNull() { - return 0 - } - return int64(C.dpiData_getInt64(d.dpiData)) -} - -// SetInt64 sets the data as int64. -func (d *Data) SetInt64(i int64) { - C.dpiData_setInt64(d.dpiData, C.int64_t(i)) -} - -// GetIntervalDS gets duration as interval date-seconds from data. -func (d *Data) GetIntervalDS() time.Duration { - if d.IsNull() { - return 0 - } - ds := C.dpiData_getIntervalDS(d.dpiData) - return time.Duration(ds.days)*24*time.Hour + - time.Duration(ds.hours)*time.Hour + - time.Duration(ds.minutes)*time.Minute + - time.Duration(ds.seconds)*time.Second + - time.Duration(ds.fseconds) -} - -// SetIntervalDS sets the duration as interval date-seconds to data. -func (d *Data) SetIntervalDS(dur time.Duration) { - C.dpiData_setIntervalDS(d.dpiData, - C.int32_t(int64(dur.Hours())/24), - C.int32_t(int64(dur.Hours())%24), C.int32_t(dur.Minutes()), C.int32_t(dur.Seconds()), - C.int32_t(dur.Nanoseconds()), - ) -} - -// GetIntervalYM gets IntervalYM from the data. -func (d *Data) GetIntervalYM() IntervalYM { - if d.IsNull() { - return IntervalYM{} - } - ym := C.dpiData_getIntervalYM(d.dpiData) - return IntervalYM{Years: int(ym.years), Months: int(ym.months)} -} - -// SetIntervalYM sets IntervalYM to the data. -func (d *Data) SetIntervalYM(ym IntervalYM) { - C.dpiData_setIntervalYM(d.dpiData, C.int32_t(ym.Years), C.int32_t(ym.Months)) -} - -// GetLob gets data as Lob. -func (d *Data) GetLob() *Lob { - if d.IsNull() { - return nil - } - return &Lob{Reader: &dpiLobReader{dpiLob: C.dpiData_getLOB(d.dpiData)}} -} - -// GetObject gets Object from data. -func (d *Data) GetObject() *Object { - if d == nil || d.dpiData == nil { - panic("null") - } - if d.IsNull() { - return nil - } - - o := C.dpiData_getObject(d.dpiData) - if o == nil { - return nil - } - obj := &Object{dpiObject: o, ObjectType: d.ObjectType} - obj.init() - return obj -} - -// SetObject sets Object to data. -func (d *Data) SetObject(o *Object) { - C.dpiData_setObject(d.dpiData, o.dpiObject) -} - -// GetStmt gets Stmt from data. -func (d *Data) GetStmt() driver.Stmt { - if d.IsNull() { - return nil - } - return &statement{dpiStmt: C.dpiData_getStmt(d.dpiData)} -} - -// SetStmt sets Stmt to data. -func (d *Data) SetStmt(s *statement) { - C.dpiData_setStmt(d.dpiData, s.dpiStmt) -} - -// GetTime gets Time from data. -func (d *Data) GetTime() time.Time { - if d.IsNull() { - return time.Time{} - } - ts := C.dpiData_getTimestamp(d.dpiData) - return time.Date( - int(ts.year), time.Month(ts.month), int(ts.day), - int(ts.hour), int(ts.minute), int(ts.second), int(ts.fsecond), - timeZoneFor(ts.tzHourOffset, ts.tzMinuteOffset), - ) - -} - -// SetTime sets Time to data. -func (d *Data) SetTime(t time.Time) { - _, z := t.Zone() - C.dpiData_setTimestamp(d.dpiData, - C.int16_t(t.Year()), C.uint8_t(t.Month()), C.uint8_t(t.Day()), - C.uint8_t(t.Hour()), C.uint8_t(t.Minute()), C.uint8_t(t.Second()), C.uint32_t(t.Nanosecond()), - C.int8_t(z/3600), C.int8_t((z%3600)/60), - ) -} - -// GetUint64 gets data as uint64. -func (d *Data) GetUint64() uint64 { - if d.IsNull() { - return 0 - } - return uint64(C.dpiData_getUint64(d.dpiData)) -} - -// SetUint64 sets data to uint64. -func (d *Data) SetUint64(u uint64) { - C.dpiData_setUint64(d.dpiData, C.uint64_t(u)) -} - -// IntervalYM holds Years and Months as interval. -type IntervalYM struct { - Years, Months int -} - -// Get returns the contents of Data. -func (d *Data) Get() interface{} { - switch d.NativeTypeNum { - case C.DPI_NATIVE_TYPE_BOOLEAN: - return d.GetBool() - case C.DPI_NATIVE_TYPE_BYTES: - return d.GetBytes() - case C.DPI_NATIVE_TYPE_DOUBLE: - return d.GetFloat64() - case C.DPI_NATIVE_TYPE_FLOAT: - return d.GetFloat32() - case C.DPI_NATIVE_TYPE_INT64: - return d.GetInt64() - case C.DPI_NATIVE_TYPE_INTERVAL_DS: - return d.GetIntervalDS() - case C.DPI_NATIVE_TYPE_INTERVAL_YM: - return d.GetIntervalYM() - case C.DPI_NATIVE_TYPE_LOB: - return d.GetLob() - case C.DPI_NATIVE_TYPE_OBJECT: - return d.GetObject() - case C.DPI_NATIVE_TYPE_STMT: - return d.GetStmt() - case C.DPI_NATIVE_TYPE_TIMESTAMP: - return d.GetTime() - case C.DPI_NATIVE_TYPE_UINT64: - return d.GetUint64() - default: - panic(fmt.Sprintf("unknown NativeTypeNum=%d", d.NativeTypeNum)) - } -} - -// IsObject returns whether the data contains an Object or not. -func (d *Data) IsObject() bool { - return d.NativeTypeNum == C.DPI_NATIVE_TYPE_OBJECT -} - -func (d *Data) reset() { - d.NativeTypeNum = 0 - d.ObjectType = ObjectType{} - if d.dpiData == nil { - d.dpiData = &C.dpiData{} - } else { - d.SetBytes(nil) - } -} diff --git a/vendor/gopkg.in/goracle.v2/drv.go b/vendor/gopkg.in/goracle.v2/drv.go deleted file mode 100644 index 89cee453dff..00000000000 --- a/vendor/gopkg.in/goracle.v2/drv.go +++ /dev/null @@ -1,912 +0,0 @@ -// Copyright 2019 Tamás Gulácsi -// -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package goracle is a database/sql/driver for Oracle DB. -// -// The connection string for the sql.Open("goracle", connString) call can be -// the simple -// login/password@sid [AS SYSDBA|AS SYSOPER] -// -// type (with sid being the sexp returned by tnsping), -// or in the form of -// ora://login:password@sid/? \ -// sysdba=0& \ -// sysoper=0& \ -// poolMinSessions=1& \ -// poolMaxSessions=1000& \ -// poolIncrement=1& \ -// connectionClass=POOLED& \ -// standaloneConnection=0& \ -// enableEvents=0& \ -// heterogeneousPool=0& \ -// prelim=0 -// -// These are the defaults. Many advocate that a static session pool (min=max, incr=0) -// is better, with 1-10 sessions per CPU thread. -// See http://docs.oracle.com/cd/E82638_01/JJUCP/optimizing-real-world-performance.htm#JJUCP-GUID-BC09F045-5D80-4AF5-93F5-FEF0531E0E1D -// You may also use ConnectionParams to configure a connection. -// -// If you specify connectionClass, that'll reuse the same session pool -// without the connectionClass, but will specify it on each session acquire. -// Thus you can cluster the session pool with classes, or use POOLED for DRCP. -package goracle - -/* -#cgo CFLAGS: -I./odpi/include -I./odpi/src -I./odpi/embed - -#include - -#include "dpi.c" -*/ -import "C" - -import ( - "context" - "database/sql" - "database/sql/driver" - "encoding/base64" - "fmt" - "hash/fnv" - "io" - "math" - "net/url" - "strconv" - "strings" - "sync" - "time" - "unsafe" - - "github.com/pkg/errors" -) - -const ( - // DefaultFetchRowCount is the number of prefetched rows by default (if not changed through FetchRowCount statement option). - DefaultFetchRowCount = 1 << 8 - - // DefaultArraySize is the length of the maximum PL/SQL array by default (if not changed through ArraySize statement option). - DefaultArraySize = 1 << 10 -) - -const ( - // DpiMajorVersion is the wanted major version of the underlying ODPI-C library. - DpiMajorVersion = C.DPI_MAJOR_VERSION - // DpiMinorVersion is the wanted minor version of the underlying ODPI-C library. - DpiMinorVersion = C.DPI_MINOR_VERSION - - // DriverName is set on the connection to be seen in the DB - DriverName = "gopkg.in/goracle.v2 : " + Version - - // DefaultPoolMinSessions specifies the default value for minSessions for pool creation. - DefaultPoolMinSessions = 1 - // DefaultPoolMaxSessions specifies the default value for maxSessions for pool creation. - DefaultPoolMaxSessions = 1000 - // DefaultPoolIncrement specifies the default value for increment for pool creation. - DefaultPoolIncrement = 1 - // DefaultConnectionClass is the default connectionClass - DefaultConnectionClass = "GORACLE" - // NoConnectionPoolingConnectionClass is a special connection class name to indicate no connection pooling. - // It is the same as setting standaloneConnection=1 - NoConnectionPoolingConnectionClass = "NO-CONNECTION-POOLING" -) - -// Number as string -type Number string - -var ( - // Int64 for converting to-from int64. - Int64 = intType{} - // Float64 for converting to-from float64. - Float64 = floatType{} - // Num for converting to-from Number (string) - Num = numType{} -) - -type intType struct{} - -func (intType) String() string { return "Int64" } -func (intType) ConvertValue(v interface{}) (driver.Value, error) { - if Log != nil { - Log("ConvertValue", "Int64", "value", v) - } - switch x := v.(type) { - case int8: - return int64(x), nil - case int16: - return int64(x), nil - case int32: - return int64(x), nil - case int64: - return x, nil - case uint16: - return int64(x), nil - case uint32: - return int64(x), nil - case uint64: - return int64(x), nil - case float32: - if _, f := math.Modf(float64(x)); f != 0 { - return int64(x), errors.Errorf("non-zero fractional part: %f", f) - } - return int64(x), nil - case float64: - if _, f := math.Modf(x); f != 0 { - return int64(x), errors.Errorf("non-zero fractional part: %f", f) - } - return int64(x), nil - case string: - if x == "" { - return 0, nil - } - return strconv.ParseInt(x, 10, 64) - case Number: - if x == "" { - return 0, nil - } - return strconv.ParseInt(string(x), 10, 64) - default: - return nil, errors.Errorf("unknown type %T", v) - } -} - -type floatType struct{} - -func (floatType) String() string { return "Float64" } -func (floatType) ConvertValue(v interface{}) (driver.Value, error) { - if Log != nil { - Log("ConvertValue", "Float64", "value", v) - } - switch x := v.(type) { - case int8: - return float64(x), nil - case int16: - return float64(x), nil - case int32: - return float64(x), nil - case uint16: - return float64(x), nil - case uint32: - return float64(x), nil - case int64: - return float64(x), nil - case uint64: - return float64(x), nil - case float32: - return float64(x), nil - case float64: - return x, nil - case string: - if x == "" { - return 0, nil - } - return strconv.ParseFloat(x, 64) - case Number: - if x == "" { - return 0, nil - } - return strconv.ParseFloat(string(x), 64) - default: - return nil, errors.Errorf("unknown type %T", v) - } -} - -type numType struct{} - -func (numType) String() string { return "Num" } -func (numType) ConvertValue(v interface{}) (driver.Value, error) { - if Log != nil { - Log("ConvertValue", "Num", "value", v) - } - switch x := v.(type) { - case string: - if x == "" { - return 0, nil - } - return x, nil - case Number: - if x == "" { - return 0, nil - } - return string(x), nil - case int8, int16, int32, int64, uint16, uint32, uint64: - return fmt.Sprintf("%d", x), nil - case float32, float64: - return fmt.Sprintf("%f", x), nil - default: - return nil, errors.Errorf("unknown type %T", v) - } -} -func (n Number) String() string { return string(n) } - -// Value returns the Number as driver.Value -func (n Number) Value() (driver.Value, error) { - return string(n), nil -} - -// Scan into the Number from a driver.Value. -func (n *Number) Scan(v interface{}) error { - if v == nil { - *n = "" - return nil - } - switch x := v.(type) { - case string: - *n = Number(x) - case Number: - *n = x - case int8, int16, int32, int64, uint16, uint32, uint64: - *n = Number(fmt.Sprintf("%d", x)) - case float32, float64: - *n = Number(fmt.Sprintf("%f", x)) - default: - return errors.Errorf("unknown type %T", v) - } - return nil -} - -// MarshalText marshals a Number to text. -func (n Number) MarshalText() ([]byte, error) { return []byte(n), nil } - -// UnmarshalText parses text into a Number. -func (n *Number) UnmarshalText(p []byte) error { - var dotNum int - for i, c := range p { - if !(c == '-' && i == 0 || '0' <= c && c <= '9') { - if c == '.' { - dotNum++ - if dotNum == 1 { - continue - } - } - return errors.Errorf("unknown char %c in %q", c, p) - } - } - *n = Number(p) - return nil -} - -// MarshalJSON marshals a Number into a JSON string. -func (n Number) MarshalJSON() ([]byte, error) { - b, err := n.MarshalText() - b2 := make([]byte, 1, 1+len(b)+1) - b2[0] = '"' - b2 = append(b2, b...) - b2 = append(b2, '"') - return b2, err -} - -// UnmarshalJSON parses a JSON string into the Number. -func (n *Number) UnmarshalJSON(p []byte) error { - *n = Number("") - if len(p) == 0 { - return nil - } - if len(p) > 2 && p[0] == '"' && p[len(p)-1] == '"' { - p = p[1 : len(p)-1] - } - return n.UnmarshalText(p) -} - -// Log function. By default, it's nil, and thus logs nothing. -// If you want to change this, change it to a github.com/go-kit/kit/log.Swapper.Log -// or analog to be race-free. -var Log func(...interface{}) error - -var defaultDrv *drv - -func init() { - defaultDrv = newDrv() - sql.Register("goracle", defaultDrv) -} - -func newDrv() *drv { - return &drv{pools: make(map[string]*connPool)} -} - -var _ = driver.Driver((*drv)(nil)) - -type drv struct { - clientVersion VersionInfo - mu sync.Mutex - dpiContext *C.dpiContext - pools map[string]*connPool -} - -type connPool struct { - dpiPool *C.dpiPool - serverVersion VersionInfo - timeZone *time.Location - tzOffSecs int -} - -func (d *drv) init() error { - d.mu.Lock() - defer d.mu.Unlock() - if d.dpiContext != nil { - return nil - } - var errInfo C.dpiErrorInfo - var dpiCtx *C.dpiContext - if C.dpiContext_create(C.uint(DpiMajorVersion), C.uint(DpiMinorVersion), - (**C.dpiContext)(unsafe.Pointer(&dpiCtx)), &errInfo, - ) == C.DPI_FAILURE { - return fromErrorInfo(errInfo) - } - d.dpiContext = dpiCtx - - var v C.dpiVersionInfo - if C.dpiContext_getClientVersion(d.dpiContext, &v) == C.DPI_FAILURE { - return errors.Wrap(d.getError(), "getClientVersion") - } - d.clientVersion.set(&v) - return nil -} - -// Open returns a new connection to the database. -// The name is a string in a driver-specific format. -func (d *drv) Open(connString string) (driver.Conn, error) { - P, err := ParseConnString(connString) - if err != nil { - return nil, err - } - - conn, err := d.openConn(P) - return conn, maybeBadConn(err) -} - -func (d *drv) ClientVersion() (VersionInfo, error) { - return d.clientVersion, nil -} - -func (d *drv) openConn(P ConnectionParams) (*conn, error) { - if err := d.init(); err != nil { - return nil, err - } - - c := conn{drv: d, connParams: P} - connString := P.String() - - defer func() { - d.mu.Lock() - if Log != nil { - Log("pools", d.pools, "conn", P.String()) - } - d.mu.Unlock() - }() - - authMode := C.dpiAuthMode(C.DPI_MODE_AUTH_DEFAULT) - // OR all the modes together - for _, elt := range []struct { - Is bool - Mode C.dpiAuthMode - }{ - {P.IsSysDBA, C.DPI_MODE_AUTH_SYSDBA}, - {P.IsSysOper, C.DPI_MODE_AUTH_SYSOPER}, - {P.IsSysASM, C.DPI_MODE_AUTH_SYSASM}, - {P.IsPrelim, C.DPI_MODE_AUTH_PRELIM}, - } { - if elt.Is { - authMode |= elt.Mode - } - } - if P.IsPrelim { - // The shared memory may not exist when Oracle is shut down. - P.ConnClass = "" - } - - extAuth := C.int(b2i(P.Username == "" && P.Password == "")) - var connCreateParams C.dpiConnCreateParams - if C.dpiContext_initConnCreateParams(d.dpiContext, &connCreateParams) == C.DPI_FAILURE { - return nil, errors.Wrap(d.getError(), "initConnCreateParams") - } - connCreateParams.authMode = authMode - connCreateParams.externalAuth = extAuth - if P.ConnClass != "" { - cConnClass := C.CString(P.ConnClass) - defer C.free(unsafe.Pointer(cConnClass)) - connCreateParams.connectionClass = cConnClass - connCreateParams.connectionClassLength = C.uint32_t(len(P.ConnClass)) - } - if !(P.IsSysDBA || P.IsSysOper || P.IsSysASM || P.IsPrelim || P.StandaloneConnection) { - d.mu.Lock() - dp := d.pools[connString] - d.mu.Unlock() - if dp != nil { - //Proxy authenticated connections to database will be provided by methods with context - c.Client, c.Server = d.clientVersion, dp.serverVersion - c.timeZone, c.tzOffSecs = dp.timeZone, dp.tzOffSecs - if err := c.acquireConn("", ""); err != nil { - return nil, err - } - err := c.init() - if err == nil { - dp.serverVersion = c.Server - dp.timeZone, dp.tzOffSecs = c.timeZone, c.tzOffSecs - } - return &c, err - } - } - - var cUserName, cPassword *C.char - if !(P.Username == "" && P.Password == "") { - cUserName, cPassword = C.CString(P.Username), C.CString(P.Password) - } - var cSid *C.char - if P.SID != "" { - cSid = C.CString(P.SID) - } - cUTF8, cConnClass := C.CString("AL32UTF8"), C.CString(P.ConnClass) - cDriverName := C.CString(DriverName) - defer func() { - if cUserName != nil { - C.free(unsafe.Pointer(cUserName)) - C.free(unsafe.Pointer(cPassword)) - } - if cSid != nil { - C.free(unsafe.Pointer(cSid)) - } - C.free(unsafe.Pointer(cUTF8)) - C.free(unsafe.Pointer(cConnClass)) - C.free(unsafe.Pointer(cDriverName)) - }() - var commonCreateParams C.dpiCommonCreateParams - if C.dpiContext_initCommonCreateParams(d.dpiContext, &commonCreateParams) == C.DPI_FAILURE { - return nil, errors.Wrap(d.getError(), "initCommonCreateParams") - } - commonCreateParams.createMode = C.DPI_MODE_CREATE_DEFAULT | C.DPI_MODE_CREATE_THREADED - if P.EnableEvents { - commonCreateParams.createMode |= C.DPI_MODE_CREATE_EVENTS - } - commonCreateParams.encoding = cUTF8 - commonCreateParams.nencoding = cUTF8 - commonCreateParams.driverName = cDriverName - commonCreateParams.driverNameLength = C.uint32_t(len(DriverName)) - - if P.IsSysDBA || P.IsSysOper || P.IsSysASM || P.IsPrelim || P.StandaloneConnection { - dc := C.malloc(C.sizeof_void) - if Log != nil { - Log("C", "dpiConn_create", "params", P.String(), "common", commonCreateParams, "conn", connCreateParams) - } - if C.dpiConn_create( - d.dpiContext, - cUserName, C.uint32_t(len(P.Username)), - cPassword, C.uint32_t(len(P.Password)), - cSid, C.uint32_t(len(P.SID)), - &commonCreateParams, - &connCreateParams, - (**C.dpiConn)(unsafe.Pointer(&dc)), - ) == C.DPI_FAILURE { - C.free(unsafe.Pointer(dc)) - return nil, errors.Wrapf(d.getError(), "username=%q sid=%q params=%+v", P.Username, P.SID, connCreateParams) - } - c.dpiConn = (*C.dpiConn)(dc) - c.currentUser = P.Username - c.newSession = true - err := c.init() - return &c, err - } - var poolCreateParams C.dpiPoolCreateParams - if C.dpiContext_initPoolCreateParams(d.dpiContext, &poolCreateParams) == C.DPI_FAILURE { - return nil, errors.Wrap(d.getError(), "initPoolCreateParams") - } - poolCreateParams.minSessions = C.uint32_t(P.MinSessions) - poolCreateParams.maxSessions = C.uint32_t(P.MaxSessions) - poolCreateParams.sessionIncrement = C.uint32_t(P.PoolIncrement) - if extAuth == 1 || P.HeterogeneousPool { - poolCreateParams.homogeneous = 0 - } - poolCreateParams.externalAuth = extAuth - poolCreateParams.getMode = C.DPI_MODE_POOL_GET_TIMEDWAIT - poolCreateParams.timeout = 300 // seconds before idle pool sessions got evicted - poolCreateParams.waitTimeout = 3 * 1000 // milliseconds to wait for a session become available - poolCreateParams.maxLifetimeSession = 3600 // maximum time in seconds till a pooled session may exist - - var dp *C.dpiPool - if Log != nil { - Log("C", "dpiPool_create", "username", P.Username, "sid", P.SID, "common", commonCreateParams, "pool", poolCreateParams) - } - //fmt.Println("POOL create", connString) - if C.dpiPool_create( - d.dpiContext, - cUserName, C.uint32_t(len(P.Username)), - cPassword, C.uint32_t(len(P.Password)), - cSid, C.uint32_t(len(P.SID)), - &commonCreateParams, - &poolCreateParams, - (**C.dpiPool)(unsafe.Pointer(&dp)), - ) == C.DPI_FAILURE { - return nil, errors.Wrapf(d.getError(), "params=%s extAuth=%v", P.String(), extAuth) - } - C.dpiPool_setStmtCacheSize(dp, 40) - d.mu.Lock() - d.pools[connString] = &connPool{dpiPool: dp} - d.mu.Unlock() - - return d.openConn(P) -} - -func (c *conn) acquireConn(user, pass string) error { - var connCreateParams C.dpiConnCreateParams - if C.dpiContext_initConnCreateParams(c.dpiContext, &connCreateParams) == C.DPI_FAILURE { - return errors.Wrap(c.getError(), "initConnCreateParams") - } - - dc := C.malloc(C.sizeof_void) - if Log != nil { - Log("C", "dpiPool_acquirePoolConnection", "conn", connCreateParams) - } - var cUserName, cPassword *C.char - defer func() { - if cUserName != nil { - C.free(unsafe.Pointer(cUserName)) - } - if cPassword != nil { - C.free(unsafe.Pointer(cPassword)) - } - }() - if user != "" { - cUserName = C.CString(user) - } - if pass != "" { - cPassword = C.CString(pass) - } - - c.drv.mu.Lock() - pool := c.pools[c.connParams.String()] - c.drv.mu.Unlock() - if C.dpiPool_acquireConnection( - pool.dpiPool, - cUserName, C.uint32_t(len(user)), cPassword, C.uint32_t(len(pass)), - &connCreateParams, - (**C.dpiConn)(unsafe.Pointer(&dc)), - ) == C.DPI_FAILURE { - C.free(unsafe.Pointer(dc)) - return errors.Wrapf(c.getError(), "acquirePoolConnection") - } - - c.dpiConn = (*C.dpiConn)(dc) - c.currentUser = user - c.newSession = connCreateParams.outNewSession == 1 - c.Client, c.Server = c.drv.clientVersion, pool.serverVersion - c.timeZone, c.tzOffSecs = pool.timeZone, pool.tzOffSecs - err := c.init() - if err == nil { - pool.serverVersion = c.Server - pool.timeZone, pool.tzOffSecs = c.timeZone, c.tzOffSecs - } - - return err -} - -// ConnectionParams holds the params for a connection (pool). -// You can use ConnectionParams{...}.StringWithPassword() -// as a connection string in sql.Open. -type ConnectionParams struct { - Username, Password, SID, ConnClass string - MinSessions, MaxSessions, PoolIncrement int - IsSysDBA, IsSysOper, IsSysASM, IsPrelim bool - HeterogeneousPool bool - StandaloneConnection bool - EnableEvents bool -} - -// String returns the string representation of ConnectionParams. -// The password is replaced with a "SECRET" string! -func (P ConnectionParams) String() string { - return P.string(true, false) -} - -// StringNoClass returns the string representation of ConnectionParams, without class info. -// The password is replaced with a "SECRET" string! -func (P ConnectionParams) StringNoClass() string { - return P.string(false, false) -} - -// StringWithPassword returns the string representation of ConnectionParams (as String() does), -// but does NOT obfuscate the password, just prints it as is. -func (P ConnectionParams) StringWithPassword() string { - return P.string(true, true) -} - -func (P ConnectionParams) string(class, withPassword bool) string { - host, path := P.SID, "" - if i := strings.IndexByte(host, '/'); i >= 0 { - host, path = host[:i], host[i:] - } - cc := "" - if class { - cc = fmt.Sprintf("connectionClass=%s&", url.QueryEscape(P.ConnClass)) - } - // params should be sorted lexicographically - password := P.Password - if !withPassword { - hsh := fnv.New64() - io.WriteString(hsh, P.Password) - password = "SECRET-" + base64.URLEncoding.EncodeToString(hsh.Sum(nil)) - } - return (&url.URL{ - Scheme: "oracle", - User: url.UserPassword(P.Username, password), - Host: host, - Path: path, - RawQuery: cc + - fmt.Sprintf("poolIncrement=%d&poolMaxSessions=%d&poolMinSessions=%d&"+ - "sysdba=%d&sysoper=%d&sysasm=%d&"+ - "standaloneConnection=%d&enableEvents=%d&"+ - "heterogeneousPool=%d&prelim=%d", - P.PoolIncrement, P.MaxSessions, P.MinSessions, - b2i(P.IsSysDBA), b2i(P.IsSysOper), b2i(P.IsSysASM), - b2i(P.StandaloneConnection), b2i(P.EnableEvents), - b2i(P.HeterogeneousPool), b2i(P.IsPrelim), - ), - }).String() -} - -// ParseConnString parses the given connection string into a struct. -func ParseConnString(connString string) (ConnectionParams, error) { - P := ConnectionParams{ - MinSessions: DefaultPoolMinSessions, - MaxSessions: DefaultPoolMaxSessions, - PoolIncrement: DefaultPoolIncrement, - ConnClass: DefaultConnectionClass, - } - if !strings.HasPrefix(connString, "oracle://") { - i := strings.IndexByte(connString, '/') - if i < 0 { - return P, errors.Errorf("no '/' in connection string") - } - P.Username, connString = connString[:i], connString[i+1:] - - uSid := strings.ToUpper(connString) - //fmt.Printf("connString=%q SID=%q\n", connString, uSid) - if strings.Contains(uSid, " AS ") { - if P.IsSysDBA = strings.HasSuffix(uSid, " AS SYSDBA"); P.IsSysDBA { - connString = connString[:len(connString)-10] - } else if P.IsSysOper = strings.HasSuffix(uSid, " AS SYSOPER"); P.IsSysOper { - connString = connString[:len(connString)-11] - } else if P.IsSysASM = strings.HasSuffix(uSid, " AS SYSASM"); P.IsSysASM { - connString = connString[:len(connString)-10] - } - } - if i = strings.IndexByte(connString, '@'); i >= 0 { - P.Password, P.SID = connString[:i], connString[i+1:] - } else { - P.Password = connString - } - if strings.HasSuffix(P.SID, ":POOLED") { - P.ConnClass, P.SID = "POOLED", P.SID[:len(P.SID)-7] - } - //fmt.Printf("connString=%q params=%s\n", connString, P) - return P, nil - } - u, err := url.Parse(connString) - if err != nil { - return P, errors.Wrap(err, connString) - } - if usr := u.User; usr != nil { - P.Username = usr.Username() - P.Password, _ = usr.Password() - } - P.SID = u.Hostname() - if u.Port() != "" { - P.SID += ":" + u.Port() - } - if u.Path != "" && u.Path != "/" { - P.SID += u.Path - } - q := u.Query() - if vv, ok := q["connectionClass"]; ok { - P.ConnClass = vv[0] - } - for _, task := range []struct { - Dest *bool - Key string - }{ - {&P.IsSysDBA, "sysdba"}, - {&P.IsSysOper, "sysoper"}, - {&P.IsSysASM, "sysasm"}, - {&P.IsPrelim, "prelim"}, - - {&P.StandaloneConnection, "standaloneConnection"}, - {&P.EnableEvents, "enableEvents"}, - {&P.HeterogeneousPool, "heterogeneousPool"}, - } { - *task.Dest = q.Get(task.Key) == "1" - } - P.StandaloneConnection = P.StandaloneConnection || P.ConnClass == NoConnectionPoolingConnectionClass - if P.IsPrelim { - P.ConnClass = "" - } - - for _, task := range []struct { - Dest *int - Key string - }{ - {&P.MinSessions, "poolMinSessions"}, - {&P.MaxSessions, "poolMaxSessions"}, - {&P.PoolIncrement, "poolIncrement"}, - } { - s := q.Get(task.Key) - if s == "" { - continue - } - var err error - *task.Dest, err = strconv.Atoi(s) - if err != nil { - return P, errors.Wrap(err, task.Key+"="+s) - } - } - if P.MinSessions > P.MaxSessions { - P.MinSessions = P.MaxSessions - } - if P.MinSessions == P.MaxSessions { - P.PoolIncrement = 0 - } else if P.PoolIncrement < 1 { - P.PoolIncrement = 1 - } - - return P, nil -} - -// OraErr is an error holding the ORA-01234 code and the message. -type OraErr struct { - message string - code int -} - -var _ = error((*OraErr)(nil)) - -// Code returns the OraErr's error code. -func (oe *OraErr) Code() int { return oe.code } - -// Message returns the OraErr's message. -func (oe *OraErr) Message() string { return oe.message } -func (oe *OraErr) Error() string { - msg := oe.Message() - if oe.code == 0 && msg == "" { - return "" - } - return fmt.Sprintf("ORA-%05d: %s", oe.code, oe.message) -} -func fromErrorInfo(errInfo C.dpiErrorInfo) *OraErr { - oe := OraErr{ - code: int(errInfo.code), - message: strings.TrimSpace(C.GoString(errInfo.message)), - } - if oe.code == 0 && strings.HasPrefix(oe.message, "ORA-") && - len(oe.message) > 9 && oe.message[9] == ':' { - if i, _ := strconv.Atoi(oe.message[4:9]); i > 0 { - oe.code = i - } - } - oe.message = strings.TrimPrefix(oe.message, fmt.Sprintf("ORA-%05d: ", oe.Code())) - return &oe -} - -// newErrorInfo is just for testing: testing cannot use Cgo... -func newErrorInfo(code int, message string) C.dpiErrorInfo { - return C.dpiErrorInfo{code: C.int32_t(code), message: C.CString(message)} -} - -// against deadcode -var _ = newErrorInfo - -func (d *drv) getError() *OraErr { - if d == nil || d.dpiContext == nil { - return &OraErr{code: -12153, message: driver.ErrBadConn.Error()} - } - var errInfo C.dpiErrorInfo - C.dpiContext_getError(d.dpiContext, &errInfo) - return fromErrorInfo(errInfo) -} - -func b2i(b bool) uint8 { - if b { - return 1 - } - return 0 -} - -// VersionInfo holds version info returned by Oracle DB. -type VersionInfo struct { - ServerRelease string - Version, Release, Update, PortRelease, PortUpdate, Full int -} - -func (V *VersionInfo) set(v *C.dpiVersionInfo) { - *V = VersionInfo{ - Version: int(v.versionNum), - Release: int(v.releaseNum), Update: int(v.updateNum), - PortRelease: int(v.portReleaseNum), PortUpdate: int(v.portUpdateNum), - Full: int(v.fullVersionNum), - } -} -func (V VersionInfo) String() string { - var s string - if V.ServerRelease != "" { - s = " [" + V.ServerRelease + "]" - } - return fmt.Sprintf("%d.%d.%d.%d.%d%s", V.Version, V.Release, V.Update, V.PortRelease, V.PortUpdate, s) -} - -var timezones = make(map[[2]C.int8_t]*time.Location) -var timezonesMu sync.RWMutex - -func timeZoneFor(hourOffset, minuteOffset C.int8_t) *time.Location { - if hourOffset == 0 && minuteOffset == 0 { - return time.UTC - } - key := [2]C.int8_t{hourOffset, minuteOffset} - timezonesMu.RLock() - tz := timezones[key] - timezonesMu.RUnlock() - if tz == nil { - timezonesMu.Lock() - if tz = timezones[key]; tz == nil { - tz = time.FixedZone( - fmt.Sprintf("%02d:%02d", hourOffset, minuteOffset), - int(hourOffset)*3600+int(minuteOffset)*60, - ) - timezones[key] = tz - } - timezonesMu.Unlock() - } - return tz -} - -type ctxKey string - -const logCtxKey = ctxKey("goracle.Log") - -type logFunc func(...interface{}) error - -func ctxGetLog(ctx context.Context) logFunc { - if lgr, ok := ctx.Value(logCtxKey).(func(...interface{}) error); ok { - return lgr - } - return Log -} - -// ContextWithLog returns a context with the given log function. -func ContextWithLog(ctx context.Context, logF func(...interface{}) error) context.Context { - return context.WithValue(ctx, logCtxKey, logF) -} - -func parseTZ(s string) (int, error) { - s = strings.TrimSpace(s) - if s == "" { - return 0, io.EOF - } - if s == "Z" || s == "UTC" { - return 0, nil - } - var tz int - if i := strings.IndexByte(s, ':'); i >= 0 { - if i64, err := strconv.ParseInt(s[i+1:], 10, 6); err != nil { - return tz, errors.Wrap(err, s) - } else { - tz = int(i64) - } - s = s[:i] - } - if i64, err := strconv.ParseInt(s, 10, 5); err != nil { - return tz, errors.Wrap(err, s) - } else { - if i64 < 0 { - tz = -tz - } - tz += int(i64 * 3600) - } - return tz, nil -} diff --git a/vendor/gopkg.in/goracle.v2/drv_10.go b/vendor/gopkg.in/goracle.v2/drv_10.go deleted file mode 100644 index e6fd6941aca..00000000000 --- a/vendor/gopkg.in/goracle.v2/drv_10.go +++ /dev/null @@ -1,106 +0,0 @@ -// +build go1.10 - -// Copyright 2019 Tamás Gulácsi -// -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package goracle - -import ( - "context" - "database/sql/driver" - "fmt" - "strings" - - "github.com/pkg/errors" -) - -var _ = driver.Connector((*connector)(nil)) - -type connector struct { - ConnectionParams - *drv - onInit func(driver.Conn) error -} - -// OpenConnector must parse the name in the same format that Driver.Open -// parses the name parameter. -func (d *drv) OpenConnector(name string) (driver.Connector, error) { - P, err := ParseConnString(name) - if err != nil { - return nil, err - } - - return connector{ConnectionParams: P, drv: d}, nil -} - -// Connect returns a connection to the database. -// Connect may return a cached connection (one previously -// closed), but doing so is unnecessary; the sql package -// maintains a pool of idle connections for efficient re-use. -// -// The provided context.Context is for dialing purposes only -// (see net.DialContext) and should not be stored or used for -// other purposes. -// -// The returned connection is only used by one goroutine at a -// time. -func (c connector) Connect(context.Context) (driver.Conn, error) { - conn, err := c.drv.openConn(c.ConnectionParams) - if err != nil || c.onInit == nil || !conn.newSession { - return conn, err - } - if err = c.onInit(conn); err != nil { - conn.Close() - return nil, err - } - return conn, nil -} - -// Driver returns the underlying Driver of the Connector, -// mainly to maintain compatibility with the Driver method -// on sql.DB. -func (c connector) Driver() driver.Driver { return c.drv } - -// NewConnector returns a driver.Connector to be used with sql.OpenDB, -// which calls the given onInit if the connection is new. -func NewConnector(name string, onInit func(driver.Conn) error) (driver.Connector, error) { - cxr, err := defaultDrv.OpenConnector(name) - if err != nil { - return nil, err - } - cx := cxr.(connector) - cx.onInit = onInit - return cx, err -} - -// NewSessionIniter returns a function suitable for use in NewConnector as onInit, -// which calls "ALTER SESSION SET =''" for each element of the given map. -func NewSessionIniter(m map[string]string) func(driver.Conn) error { - return func(cx driver.Conn) error { - for k, v := range m { - qry := fmt.Sprintf("ALTER SESSION SET %s = '%s'", k, strings.ReplaceAll(v, "'", "''")) - st, err := cx.Prepare(qry) - if err != nil { - return errors.Wrap(err, qry) - } - _, err = st.Exec(nil) //nolint:SA1019 - st.Close() - if err != nil { - return err - } - } - return nil - } -} diff --git a/vendor/gopkg.in/goracle.v2/drv_posix.go b/vendor/gopkg.in/goracle.v2/drv_posix.go deleted file mode 100644 index 0f3de24337e..00000000000 --- a/vendor/gopkg.in/goracle.v2/drv_posix.go +++ /dev/null @@ -1,21 +0,0 @@ -// +build !windows - -// Copyright 2017 Tamás Gulácsi -// -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package goracle - -// #cgo LDFLAGS: -ldl -lpthread -import "C" diff --git a/vendor/gopkg.in/goracle.v2/go.mod b/vendor/gopkg.in/goracle.v2/go.mod deleted file mode 100644 index dddc925735b..00000000000 --- a/vendor/gopkg.in/goracle.v2/go.mod +++ /dev/null @@ -1,10 +0,0 @@ -module gopkg.in/goracle.v2 - -require ( - github.com/go-kit/kit v0.8.0 - github.com/go-logfmt/logfmt v0.4.0 // indirect - github.com/go-stack/stack v1.8.0 // indirect - github.com/google/go-cmp v0.2.0 - github.com/pkg/errors v0.8.0 - golang.org/x/sync v0.0.0-20181108010431-42b317875d0f -) diff --git a/vendor/gopkg.in/goracle.v2/go.sum b/vendor/gopkg.in/goracle.v2/go.sum deleted file mode 100644 index 3bcd4a1c117..00000000000 --- a/vendor/gopkg.in/goracle.v2/go.sum +++ /dev/null @@ -1,14 +0,0 @@ -github.com/go-kit/kit v0.8.0 h1:Wz+5lgoB0kkuqLEc6NVmwRknTKP6dTGbSqvhZtBI/j0= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-logfmt/logfmt v0.4.0 h1:MP4Eh7ZCb31lleYCFuwm0oe4/YGak+5l1vA2NOE80nA= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/vendor/gopkg.in/goracle.v2/stmt_go09.go b/vendor/gopkg.in/goracle.v2/stmt_go09.go deleted file mode 100644 index 6c731f8ed64..00000000000 --- a/vendor/gopkg.in/goracle.v2/stmt_go09.go +++ /dev/null @@ -1,52 +0,0 @@ -// +build !go1.10 - -// Copyright 2017 Tamás Gulácsi -// -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package goracle - -/* -#include -#include "dpiImpl.h" -*/ -import "C" -import ( - "bytes" - "sync" - "unsafe" -) - -const go10 = false - -func dpiSetFromString(dv *C.dpiVar, pos C.uint32_t, x string) { - b := []byte(x) - C.dpiVar_setFromBytes(dv, pos, (*C.char)(unsafe.Pointer(&b[0])), C.uint32_t(len(b))) -} - -var stringBuilders = stringBuilderPool{ - p: &sync.Pool{New: func() interface{} { return bytes.NewBuffer(make([]byte, 0, 1024)) }}, -} - -type stringBuilderPool struct { - p *sync.Pool -} - -func (sb stringBuilderPool) Get() *bytes.Buffer { - return sb.p.Get().(*bytes.Buffer) -} -func (sb *stringBuilderPool) Put(b *bytes.Buffer) { - b.Reset() - sb.p.Put(b) -} diff --git a/vendor/gopkg.in/goracle.v2/stmt_go10.go b/vendor/gopkg.in/goracle.v2/stmt_go10.go deleted file mode 100644 index 5bc1da80073..00000000000 --- a/vendor/gopkg.in/goracle.v2/stmt_go10.go +++ /dev/null @@ -1,78 +0,0 @@ -// +build go1.10 - -// Copyright 2017 Tamás Gulácsi -// -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package goracle - -/* -#include -#include "dpiImpl.h" - -void goracle_setFromString(dpiVar *dv, uint32_t pos, const _GoString_ value) { - uint32_t length; - length = _GoStringLen(value); - if( length == 0 ) { - return; - } - dpiVar_setFromBytes(dv, pos, _GoStringPtr(value), length); -} -*/ -import "C" -import ( - //"context" - "strings" - "sync" -) - -const go10 = true - -func dpiSetFromString(dv *C.dpiVar, pos C.uint32_t, x string) { - C.goracle_setFromString(dv, pos, x) -} - -var stringBuilders = stringBuilderPool{ - p: &sync.Pool{New: func() interface{} { return &strings.Builder{} }}, -} - -type stringBuilderPool struct { - p *sync.Pool -} - -func (sb stringBuilderPool) Get() *strings.Builder { - return sb.p.Get().(*strings.Builder) -} -func (sb *stringBuilderPool) Put(b *strings.Builder) { - b.Reset() - sb.p.Put(b) -} - -/* -// ResetSession is called while a connection is in the connection -// pool. No queries will run on this connection until this method returns. -// -// If the connection is bad this should return driver.ErrBadConn to prevent -// the connection from being returned to the connection pool. Any other -// error will be discarded. -func (c *conn) ResetSession(ctx context.Context) error { - if Log != nil { - Log("msg", "ResetSession", "conn", c.dpiConn) - } - //subCtx, cancel := context.WithTimeout(ctx, 30*time.Second) - //err := c.Ping(subCtx) - //cancel() - return c.Ping(ctx) -} -*/ diff --git a/vendor/vendor.json b/vendor/vendor.json index e37769ac625..4dca573df82 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -3448,6 +3448,15 @@ "revision": "37bf87eef99d69c4f1d3528bd66e3a87dc201472", "revisionTime": "2019-09-30T11:59:46Z" }, + { + "checksumSHA1": "xJkfP+WyfKJSBcEa+8T15QjNIr4=", + "path": "github.com/godror/godror", + "revision": "0123d49bd73e1bed106ac8b6af67f943fbbf06e2", + "revisionTime": "2020-01-12T11:05:39Z", + "tree": true, + "version": "v0.10.4", + "versionExact": "v0.10.4" + }, { "checksumSHA1": "MlaWEe1K+Kpb9wDF88qPoqO1uro=", "path": "github.com/gofrs/flock", @@ -5666,12 +5675,16 @@ "versionExact": "release-branch.go1.13" }, { - "checksumSHA1": "WvhCpgIKNQ1psrswDf1GC5hFKWM=", - "path": "google.golang.org/api/compute/v1", - "revision": "8a410c21381766a810817fd6200fce8838ecb277", - "revisionTime": "2019-11-15T18:09:15Z", - "version": "v0.14.0", - "versionExact": "v0.14.0" + "checksumSHA1": "uIgpefsunMZTr8uZTJKcevvU/yg=", + "path": "golang.org/x/xerrors", + "revision": "9bdfabe68543c54f90421aeb9a60ef8061b5b544", + "revisionTime": "2019-07-19T19:12:34Z" + }, + { + "checksumSHA1": "LnzK4nslUNXBIfAt9PbXCJCvMdA=", + "path": "golang.org/x/xerrors/internal", + "revision": "9bdfabe68543c54f90421aeb9a60ef8061b5b544", + "revisionTime": "2019-07-19T19:12:34Z" }, { "checksumSHA1": "xzYkHGnGgOHW4QNWLR4jbx+81P0=", @@ -5681,6 +5694,14 @@ "version": "v0.7.0", "versionExact": "v0.7.0" }, + { + "checksumSHA1": "WvhCpgIKNQ1psrswDf1GC5hFKWM=", + "path": "google.golang.org/api/compute/v1", + "revision": "8a410c21381766a810817fd6200fce8838ecb277", + "revisionTime": "2019-11-15T18:09:15Z", + "version": "v0.14.0", + "versionExact": "v0.14.0" + }, { "checksumSHA1": "FhzGDPlkW5SaQGtSgKnjQAiYVk0=", "path": "google.golang.org/api/gensupport", @@ -5721,6 +5742,12 @@ "version": "v0.7.0", "versionExact": "v0.7.0" }, + { + "path": "google.golang.org/api/internal/gensupport", + "revision": "02490b97dff7cfde1995bd77de808fd27053bc87", + "version": "v0.7.0", + "versionExact": "v0.7.0" + }, { "checksumSHA1": "I4Oe5Q+AuaxmN3duL38r2evqGKk=", "path": "google.golang.org/api/internal/gensupport", @@ -5736,12 +5763,6 @@ "revisionTime": "2019-11-15T18:09:15Z", "version": "v0.14.0", "versionExact": "v0.14.0" - }, - { - "path": "google.golang.org/api/internal/gensupport", - "revision": "02490b97dff7cfde1995bd77de808fd27053bc87", - "version": "v0.7.0", - "versionExact": "v0.7.0" }, { "checksumSHA1": "zh9AcT6oNvhnOqb7w7njY48TkvI=", @@ -6394,12 +6415,6 @@ "version": "v1.25.1", "versionExact": "v1.25.1" }, - { - "checksumSHA1": "+/UD9mGRnKxOhZW3+B+VJdIIPn8=", - "path": "gopkg.in/goracle.v2", - "revision": "3222d7159b45fce95150f06a57e1bcc2868108d3", - "revisionTime": "2019-05-30T18:40:54Z" - }, { "checksumSHA1": "6f8MEU31llHM1sLM/GGH4/Qxu0A=", "path": "gopkg.in/inf.v0", diff --git a/winlogbeat/winlogbeat.reference.yml b/winlogbeat/winlogbeat.reference.yml index 81eab60bc5f..4e995b0504b 100644 --- a/winlogbeat/winlogbeat.reference.yml +++ b/winlogbeat/winlogbeat.reference.yml @@ -408,9 +408,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # List of root certificates for HTTPS server verifications #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] @@ -500,9 +500,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -673,9 +673,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Certificate for SSL client authentication #ssl.certificate: "/etc/pki/client/cert.pem" @@ -785,9 +785,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -1010,7 +1010,7 @@ setup.template.settings: #setup.ilm.pattern: "{now/d}-000001" # Set the lifecycle policy name. The default policy name is -# 'winlogbeat-%{[agent.version]}'. +# 'winlogbeat'. #setup.ilm.policy_name: "mypolicy" # The path to a JSON file that contains a lifecycle policy configuration. Used @@ -1054,9 +1054,9 @@ setup.kibana: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -1230,9 +1230,9 @@ logging.files: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -1260,6 +1260,14 @@ logging.files: #metrics.period: 10s #state.period: 1m +# The `monitoring.cloud.id` setting overwrites the `monitoring.elasticsearch.hosts` +# setting. You can find the value for this setting in the Elastic Cloud web UI. +#monitoring.cloud.id: + +# The `monitoring.cloud.auth` setting overwrites the `monitoring.elasticsearch.username` +# and `monitoring.elasticsearch.password` settings. The format is `:`. +#monitoring.cloud.auth: + #================================ HTTP Endpoint ====================================== # Each beat can expose internal metrics through a HTTP endpoint. For security # reasons the endpoint is disabled by default. This feature is currently experimental. diff --git a/x-pack/auditbeat/auditbeat.reference.yml b/x-pack/auditbeat/auditbeat.reference.yml index 55b57e87ec1..ef9c19cecfe 100644 --- a/x-pack/auditbeat/auditbeat.reference.yml +++ b/x-pack/auditbeat/auditbeat.reference.yml @@ -536,9 +536,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # List of root certificates for HTTPS server verifications #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] @@ -628,9 +628,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -801,9 +801,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Certificate for SSL client authentication #ssl.certificate: "/etc/pki/client/cert.pem" @@ -913,9 +913,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -1138,7 +1138,7 @@ setup.template.settings: #setup.ilm.pattern: "{now/d}-000001" # Set the lifecycle policy name. The default policy name is -# 'auditbeat-%{[agent.version]}'. +# 'auditbeat'. #setup.ilm.policy_name: "mypolicy" # The path to a JSON file that contains a lifecycle policy configuration. Used @@ -1182,9 +1182,9 @@ setup.kibana: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -1358,9 +1358,9 @@ logging.files: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -1388,6 +1388,14 @@ logging.files: #metrics.period: 10s #state.period: 1m +# The `monitoring.cloud.id` setting overwrites the `monitoring.elasticsearch.hosts` +# setting. You can find the value for this setting in the Elastic Cloud web UI. +#monitoring.cloud.id: + +# The `monitoring.cloud.auth` setting overwrites the `monitoring.elasticsearch.username` +# and `monitoring.elasticsearch.password` settings. The format is `:`. +#monitoring.cloud.auth: + #================================ HTTP Endpoint ====================================== # Each beat can expose internal metrics through a HTTP endpoint. For security # reasons the endpoint is disabled by default. This feature is currently experimental. diff --git a/x-pack/auditbeat/docs/modules/system.asciidoc b/x-pack/auditbeat/docs/modules/system.asciidoc index dc80845aa24..361af353c43 100644 --- a/x-pack/auditbeat/docs/modules/system.asciidoc +++ b/x-pack/auditbeat/docs/modules/system.asciidoc @@ -2,9 +2,10 @@ This file is generated! See scripts/docs_collector.py //// +:modulename: system + [id="{beatname_lc}-module-system"] [role="xpack"] - == System Module beta[] @@ -72,8 +73,9 @@ sample suggested configuration. user.detect_password_changes: true ---- -*`period`*:: The frequency at which the datasets check for changes. For most -datasets - esp. `process` and `socket` - a shorter period is recommended. +This module also supports the +<> +described later. *`state.period`*:: The frequency at which the datasets send full state information. This option can be overridden per dataset using `{dataset}.state.period`. @@ -85,8 +87,7 @@ the `beat.db` file to detect changes between Auditbeat restarts. The `beat.db` f should be readable only by the root user and be treated similar to the shadow file itself. -*`keep_null`*:: If this option is set to true, fields with `null` values will be -published in the output document. By default, `keep_null` is set to `false`. +include::{docdir}/auditbeat-options.asciidoc[] [float] === Suggested configuration @@ -151,6 +152,9 @@ auditbeat.modules: login.btmp_file_pattern: /var/log/btmp* ---- + +:modulename!: + [float] === Datasets diff --git a/x-pack/auditbeat/module/system/_meta/docs.asciidoc b/x-pack/auditbeat/module/system/_meta/docs.asciidoc index 30d97edb478..2e91d2db116 100644 --- a/x-pack/auditbeat/module/system/_meta/docs.asciidoc +++ b/x-pack/auditbeat/module/system/_meta/docs.asciidoc @@ -1,5 +1,4 @@ [role="xpack"] - == System Module beta[] @@ -67,8 +66,9 @@ sample suggested configuration. user.detect_password_changes: true ---- -*`period`*:: The frequency at which the datasets check for changes. For most -datasets - esp. `process` and `socket` - a shorter period is recommended. +This module also supports the +<> +described later. *`state.period`*:: The frequency at which the datasets send full state information. This option can be overridden per dataset using `{dataset}.state.period`. @@ -80,8 +80,7 @@ the `beat.db` file to detect changes between Auditbeat restarts. The `beat.db` f should be readable only by the root user and be treated similar to the shadow file itself. -*`keep_null`*:: If this option is set to true, fields with `null` values will be -published in the output document. By default, `keep_null` is set to `false`. +include::{docdir}/auditbeat-options.asciidoc[] [float] === Suggested configuration diff --git a/x-pack/auditbeat/module/system/socket/events.go b/x-pack/auditbeat/module/system/socket/events.go index 043a0565b1b..a5cb5c0ebee 100644 --- a/x-pack/auditbeat/module/system/socket/events.go +++ b/x-pack/auditbeat/module/system/socket/events.go @@ -534,14 +534,16 @@ type udpSendMsgCall struct { LPort uint16 `kprobe:"lport"` RPort uint16 `kprobe:"rport"` AltRPort uint16 `kprobe:"altrport"` + // SIPtr is the struct sockaddr_in pointer. + SIPtr uintptr `kprobe:"siptr"` + // SIAF is the address family in (struct sockaddr_in*)->sin_family. + SIAF uint16 `kprobe:"siaf"` } func (e *udpSendMsgCall) asFlow() flow { raddr, rport := e.RAddr, e.RPort - if raddr == 0 { + if e.SIPtr == 0 || e.SIAF != unix.AF_INET { raddr = e.AltRAddr - } - if rport == 0 { rport = e.AltRPort } return flow{ @@ -586,14 +588,16 @@ type udpv6SendMsgCall struct { LPort uint16 `kprobe:"lport"` RPort uint16 `kprobe:"rport"` AltRPort uint16 `kprobe:"altrport"` + // SI6Ptr is the struct sockaddr_in6 pointer. + SI6Ptr uintptr `kprobe:"si6ptr"` + // Si6AF is the address family field ((struct sockaddr_in6*)->sin6_family) + SI6AF uint16 `kprobe:"si6af"` } func (e *udpv6SendMsgCall) asFlow() flow { raddra, raddrb, rport := e.RAddrA, e.RAddrB, e.RPort - if raddra == 0 && raddrb == 0 { + if e.SI6Ptr == 0 || e.SI6AF != unix.AF_INET6 { raddra, raddrb = e.AltRAddrA, e.AltRAddrB - } - if rport == 0 { rport = e.AltRPort } return flow{ diff --git a/x-pack/auditbeat/module/system/socket/guess/deref.go b/x-pack/auditbeat/module/system/socket/guess/deref.go new file mode 100644 index 00000000000..0701a33ebf3 --- /dev/null +++ b/x-pack/auditbeat/module/system/socket/guess/deref.go @@ -0,0 +1,139 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +// +build linux,386 linux,amd64 + +package guess + +import ( + "encoding/hex" + "os" + "strconv" + "syscall" + + "github.com/elastic/beats/libbeat/common" + "github.com/elastic/beats/x-pack/auditbeat/module/system/socket/helper" + "github.com/elastic/beats/x-pack/auditbeat/tracing" +) + +/* + This is not an actual guess but a helper to check if the kernel kprobe + subsystem returns garbage after dereferencing a null pointer. + + This code is run when the AUDITBEAT_SYSTEM_SOCKET_CHECK_DEREF environment + variable is set to a value greater than 0. When set, it will run the given + number of times, print the hexdump to the debug logs if non-zero memory is + found and set the NULL_PTR_DEREF_IS_OK (bool) variable. +*/ + +func init() { + if err := Registry.AddGuess(&guessDeref{}); err != nil { + panic(err) + } +} + +const ( + flagName = "NULL_PTR_DEREF_IS_OK" + envVar = "AUDITBEAT_SYSTEM_SOCKET_CHECK_DEREF" +) + +type guessDeref struct { + ctx Context + tries int + garbage bool +} + +// Condition allows the guess to run if the environment variable is set to a +// decimal value greater than zero. +func (g *guessDeref) Condition(ctx Context) (run bool, err error) { + v := os.Getenv(envVar) + if v == "" { + return false, nil + } + if g.tries, err = strconv.Atoi(v); err != nil || g.tries <= 0 { + return false, nil + } + return true, nil +} + +// Name of this guess. +func (g *guessDeref) Name() string { + return "guess_deref" +} + +// Provides returns the names of discovered variables. +func (g *guessDeref) Provides() []string { + return []string{ + flagName, + } +} + +// Requires declares the variables required to run this guess. +func (g *guessDeref) Requires() []string { + return []string{ + "SYS_UNAME", + } +} + +// Probes returns a kprobe on uname() that dumps the first bytes +// pointed to by its first parameter. +func (g *guessDeref) Probes() ([]helper.ProbeDef, error) { + return []helper.ProbeDef{ + { + Probe: tracing.Probe{ + Type: tracing.TypeKProbe, + Name: "guess_null_ptr_deref", + Address: "{{.SYS_UNAME}}", + Fetchargs: helper.MakeMemoryDump("{{.P1}}", 0, credDumpBytes), + }, + Decoder: tracing.NewDumpDecoder, + }, + }, nil +} + +// Prepare is a no-op. +func (g *guessDeref) Prepare(ctx Context) error { + g.ctx = ctx + return nil +} + +// Terminate is a no-op. +func (g *guessDeref) Terminate() error { + return nil +} + +// MaxRepeats returns the configured number of repeats. +func (g *guessDeref) MaxRepeats() int { + return g.tries +} + +// Extract receives the memory read through a null pointer and checks if it's +// zero or garbage. +func (g *guessDeref) Extract(ev interface{}) (common.MapStr, bool) { + raw := ev.([]byte) + if len(raw) != credDumpBytes { + return nil, false + } + for _, val := range raw { + if val != 0 { + g.ctx.Log.Errorf("Found non-zero memory:\n%s", hex.Dump(raw)) + g.garbage = true + break + } + } + // Repeat until completed all tries + if g.tries--; g.tries > 0 { + return nil, true + } + return common.MapStr{ + flagName: !g.garbage, + }, true +} + +// Trigger invokes the uname syscall with a null parameter. +func (g *guessDeref) Trigger() error { + var ptr *syscall.Utsname + syscall.Uname(ptr) + return nil +} diff --git a/x-pack/auditbeat/module/system/socket/kprobes.go b/x-pack/auditbeat/module/system/socket/kprobes.go index 71887f0108b..340e2e520cb 100644 --- a/x-pack/auditbeat/module/system/socket/kprobes.go +++ b/x-pack/auditbeat/module/system/socket/kprobes.go @@ -293,7 +293,7 @@ var sharedKProbes = []helper.ProbeDef{ Probe: tracing.Probe{ Name: "udp_sendmsg_in", Address: "udp_sendmsg", - Fetchargs: "sock={{.UDP_SENDMSG_SOCK}} size={{.UDP_SENDMSG_LEN}} laddr=+{{.INET_SOCK_LADDR}}({{.UDP_SENDMSG_SOCK}}):u32 lport=+{{.INET_SOCK_LPORT}}({{.UDP_SENDMSG_SOCK}}):u16 raddr=+{{.SOCKADDR_IN_ADDR}}(+0({{.UDP_SENDMSG_MSG}})):u32 rport=+{{.SOCKADDR_IN_PORT}}(+0({{.UDP_SENDMSG_MSG}})):u16 altraddr=+{{.INET_SOCK_RADDR}}({{.UDP_SENDMSG_SOCK}}):u32 altrport=+{{.INET_SOCK_RPORT}}({{.UDP_SENDMSG_SOCK}}):u16", + Fetchargs: "sock={{.UDP_SENDMSG_SOCK}} size={{.UDP_SENDMSG_LEN}} laddr=+{{.INET_SOCK_LADDR}}({{.UDP_SENDMSG_SOCK}}):u32 lport=+{{.INET_SOCK_LPORT}}({{.UDP_SENDMSG_SOCK}}):u16 raddr=+{{.SOCKADDR_IN_ADDR}}(+0({{.UDP_SENDMSG_MSG}})):u32 siptr=+0({{.UDP_SENDMSG_MSG}}) siaf=+{{.SOCKADDR_IN_AF}}(+0({{.UDP_SENDMSG_MSG}})):u16 rport=+{{.SOCKADDR_IN_PORT}}(+0({{.UDP_SENDMSG_MSG}})):u16 altraddr=+{{.INET_SOCK_RADDR}}({{.UDP_SENDMSG_SOCK}}):u32 altrport=+{{.INET_SOCK_RPORT}}({{.UDP_SENDMSG_SOCK}}):u16", }, Decoder: helper.NewStructDecoder(func() interface{} { return new(udpSendMsgCall) }), }, @@ -455,7 +455,7 @@ var ipv6KProbes = []helper.ProbeDef{ Probe: tracing.Probe{ Name: "udpv6_sendmsg_in", Address: "udpv6_sendmsg", - Fetchargs: "sock={{.UDP_SENDMSG_SOCK}} size={{.UDP_SENDMSG_LEN}} laddra={{.INET_SOCK_V6_LADDR_A}}({{.UDP_SENDMSG_SOCK}}){{.INET_SOCK_V6_TERM}} laddrb={{.INET_SOCK_V6_LADDR_B}}({{.UDP_SENDMSG_SOCK}}){{.INET_SOCK_V6_TERM}} lport=+{{.INET_SOCK_LPORT}}({{.UDP_SENDMSG_SOCK}}):u16 raddra=+{{.SOCKADDR_IN6_ADDRA}}(+0({{.UDP_SENDMSG_MSG}})):u64 raddrb=+{{.SOCKADDR_IN6_ADDRB}}(+0({{.UDP_SENDMSG_MSG}})):u64 rport=+{{.SOCKADDR_IN6_PORT}}(+0({{.UDP_SENDMSG_MSG}})):u16 altraddra={{.INET_SOCK_V6_RADDR_A}}({{.UDP_SENDMSG_SOCK}}){{.INET_SOCK_V6_TERM}} altraddrb={{.INET_SOCK_V6_RADDR_B}}({{.UDP_SENDMSG_SOCK}}){{.INET_SOCK_V6_TERM}} altrport=+{{.INET_SOCK_RPORT}}({{.UDP_SENDMSG_SOCK}}):u16", + Fetchargs: "sock={{.UDP_SENDMSG_SOCK}} size={{.UDP_SENDMSG_LEN}} laddra={{.INET_SOCK_V6_LADDR_A}}({{.UDP_SENDMSG_SOCK}}){{.INET_SOCK_V6_TERM}} laddrb={{.INET_SOCK_V6_LADDR_B}}({{.UDP_SENDMSG_SOCK}}){{.INET_SOCK_V6_TERM}} lport=+{{.INET_SOCK_LPORT}}({{.UDP_SENDMSG_SOCK}}):u16 raddra=+{{.SOCKADDR_IN6_ADDRA}}(+0({{.UDP_SENDMSG_MSG}})):u64 raddrb=+{{.SOCKADDR_IN6_ADDRB}}(+0({{.UDP_SENDMSG_MSG}})):u64 rport=+{{.SOCKADDR_IN6_PORT}}(+0({{.UDP_SENDMSG_MSG}})):u16 altraddra={{.INET_SOCK_V6_RADDR_A}}({{.UDP_SENDMSG_SOCK}}){{.INET_SOCK_V6_TERM}} altraddrb={{.INET_SOCK_V6_RADDR_B}}({{.UDP_SENDMSG_SOCK}}){{.INET_SOCK_V6_TERM}} altrport=+{{.INET_SOCK_RPORT}}({{.UDP_SENDMSG_SOCK}}):u16 si6ptr=+0({{.UDP_SENDMSG_MSG}}) si6af=+{{.SOCKADDR_IN6_AF}}(+0({{.UDP_SENDMSG_MSG}})):u16", }, Decoder: helper.NewStructDecoder(func() interface{} { return new(udpv6SendMsgCall) }), }, diff --git a/x-pack/auditbeat/module/system/socket/state_test.go b/x-pack/auditbeat/module/system/socket/state_test.go index 8133280b4c8..efff2613a1c 100644 --- a/x-pack/auditbeat/module/system/socket/state_test.go +++ b/x-pack/auditbeat/module/system/socket/state_test.go @@ -16,6 +16,7 @@ import ( "github.com/joeshaw/multierror" "github.com/pkg/errors" "github.com/stretchr/testify/assert" + "golang.org/x/sys/unix" "github.com/elastic/beats/libbeat/beat" "github.com/elastic/beats/x-pack/auditbeat/module/system/socket/dns" @@ -148,11 +149,9 @@ func TestUDPOutgoingSinglePacketWithProcess(t *testing.T) { Sock: sock, Size: 123, LAddr: lAddr, - RAddr: rAddr, - AltRAddr: 0, + AltRAddr: rAddr, LPort: lPort, - RPort: rPort, - AltRPort: 0, + AltRPort: rPort, }, &inetReleaseCall{Meta: meta(1234, 1235, 17), Sock: sock}, &doExit{Meta: meta(1234, 1234, 18)}, @@ -293,6 +292,14 @@ func ipv4(ip string) uint32 { return tracing.MachineEndian.Uint32(netIP) } +func ipv6(ip string) (hi uint64, lo uint64) { + netIP := net.ParseIP(ip).To16() + if netIP == nil { + panic("bad ip") + } + return tracing.MachineEndian.Uint64(netIP[:]), tracing.MachineEndian.Uint64(netIP[8:]) +} + func feedEvents(evs []event, st *state, t *testing.T) error { for idx, ev := range evs { t.Logf("Delivering event %d: %s", idx, ev.String()) @@ -515,3 +522,62 @@ func TestDNSTracker(t *testing.T) { }.Run(t) }) } + +func TestUDPSendMsgAltLogic(t *testing.T) { + const expectedIPv4 = "6 probe=0 pid=1234 tid=1235 udp_sendmsg(sock=0x0, size=0, 10.11.12.13:1010 -> 10.20.30.40:1234)" + const expectedIPv6 = "6 probe=0 pid=1234 tid=1235 udpv6_sendmsg(sock=0x0, size=0, [fddd::bebe]:1010 -> [fddd::cafe]:1234)" + t.Run("ipv4 non-connected", func(t *testing.T) { + ev := udpSendMsgCall{ + Meta: meta(1234, 1235, 6), + LAddr: ipv4("10.11.12.13"), + LPort: be16(1010), + RAddr: ipv4("10.20.30.40"), + RPort: be16(1234), + AltRAddr: ipv4("192.168.255.255"), + AltRPort: be16(555), + SIPtr: 0x7fffffff, + SIAF: unix.AF_INET, + } + assert.Equal(t, expectedIPv4, ev.String()) + }) + t.Run("ipv4 connected", func(t *testing.T) { + ev := udpSendMsgCall{ + Meta: meta(1234, 1235, 6), + LAddr: ipv4("10.11.12.13"), + LPort: be16(1010), + RAddr: ipv4("192.168.255.255"), + RPort: be16(555), + AltRAddr: ipv4("10.20.30.40"), + AltRPort: be16(1234), + } + assert.Equal(t, expectedIPv4, ev.String()) + }) + t.Run("ipv6 non-connected", func(t *testing.T) { + ev := udpv6SendMsgCall{ + Meta: meta(1234, 1235, 6), + LPort: be16(1010), + RPort: be16(1234), + AltRPort: be16(555), + SI6Ptr: 0x7fffffff, + SI6AF: unix.AF_INET6, + } + ev.LAddrA, ev.LAddrB = ipv6("fddd::bebe") + ev.RAddrA, ev.RAddrB = ipv6("fddd::cafe") + ev.AltRAddrA, ev.AltRAddrB = ipv6("fddd::bad:bad") + assert.Equal(t, expectedIPv6, ev.String()) + }) + + t.Run("ipv6 connected", func(t *testing.T) { + ev := udpv6SendMsgCall{ + Meta: meta(1234, 1235, 6), + LPort: be16(1010), + RPort: be16(555), + AltRPort: be16(1234), + } + ev.LAddrA, ev.LAddrB = ipv6("fddd::bebe") + ev.RAddrA, ev.RAddrB = ipv6("fddd::bad:bad") + ev.AltRAddrA, ev.AltRAddrB = ipv6("fddd::cafe") + assert.Equal(t, expectedIPv6, ev.String()) + }) + +} diff --git a/x-pack/dockerlogbeat/main.go b/x-pack/dockerlogbeat/main.go index d60a12cbece..d763126f2dc 100644 --- a/x-pack/dockerlogbeat/main.go +++ b/x-pack/dockerlogbeat/main.go @@ -15,7 +15,9 @@ import ( _ "github.com/elastic/beats/libbeat/outputs/console" _ "github.com/elastic/beats/libbeat/outputs/elasticsearch" _ "github.com/elastic/beats/libbeat/outputs/fileout" + _ "github.com/elastic/beats/libbeat/outputs/kafka" _ "github.com/elastic/beats/libbeat/outputs/logstash" + _ "github.com/elastic/beats/libbeat/outputs/redis" _ "github.com/elastic/beats/libbeat/publisher/queue/memqueue" _ "github.com/elastic/beats/libbeat/publisher/queue/spool" "github.com/elastic/beats/libbeat/service" diff --git a/x-pack/dockerlogbeat/pipelinemanager/libbeattools.go b/x-pack/dockerlogbeat/pipelinemanager/libbeattools.go index 04caca748db..e6ff0d8dbf7 100644 --- a/x-pack/dockerlogbeat/pipelinemanager/libbeattools.go +++ b/x-pack/dockerlogbeat/pipelinemanager/libbeattools.go @@ -15,6 +15,7 @@ import ( yaml "gopkg.in/yaml.v2" "github.com/elastic/beats/libbeat/beat" + "github.com/elastic/beats/libbeat/cloudid" "github.com/elastic/beats/libbeat/common" "github.com/elastic/beats/libbeat/idxmgmt" "github.com/elastic/beats/libbeat/logp" @@ -67,6 +68,13 @@ func loadNewPipeline(logOptsConfig map[string]string, name string, log *logp.Log if err != nil { return nil, err } + + // Attach CloudID config if needed + err = cloudid.OverwriteSettings(cfg) + if err != nil { + return nil, errors.Wrap(err, "Error creating CloudID") + } + config := containerConfig{} err = cfg.Unpack(&config) if err != nil { diff --git a/x-pack/filebeat/filebeat.reference.yml b/x-pack/filebeat/filebeat.reference.yml index 28f911bfa36..6d4d4d09aeb 100644 --- a/x-pack/filebeat/filebeat.reference.yml +++ b/x-pack/filebeat/filebeat.reference.yml @@ -102,7 +102,13 @@ filebeat.modules: # AWS SQS queue url #var.queue_url: https://sqs.myregion.amazonaws.com/123456/myqueue + # Filename of AWS credential file + # If not set "$HOME/.aws/credentials" is used on Linux/Mac + # "%UserProfile%\.aws\credentials" is used on Windows + #var.shared_credential_file: /etc/filebeat/aws_credentials + # Profile name for aws credential + # If not set the default profile is used #var.credential_profile_name: fb-aws elb: @@ -111,7 +117,13 @@ filebeat.modules: # AWS SQS queue url #var.queue_url: https://sqs.myregion.amazonaws.com/123456/myqueue + # Filename of AWS credential file + # If not set "$HOME/.aws/credentials" is used on Linux/Mac + # "%UserProfile%\.aws\credentials" is used on Windows + #var.shared_credential_file: /etc/filebeat/aws_credentials + # Profile name for aws credential + # If not set the default profile is used #var.credential_profile_name: fb-aws vpcflow: @@ -120,7 +132,13 @@ filebeat.modules: # AWS SQS queue url #var.queue_url: https://sqs.myregion.amazonaws.com/123456/myqueue + # Filename of AWS credential file + # If not set "$HOME/.aws/credentials" is used on Linux/Mac + # "%UserProfile%\.aws\credentials" is used on Windows + #var.shared_credential_file: /etc/filebeat/aws_credentials + # Profile name for aws credential + # If not set the default profile is used #var.credential_profile_name: fb-aws cloudtrail: @@ -129,7 +147,13 @@ filebeat.modules: # AWS SQS queue url #var.queue_url: https://sqs.myregion.amazonaws.com/123456/myqueue + # Filename of AWS credential file + # If not set "$HOME/.aws/credentials" is used on Linux/Mac + # "%UserProfile%\.aws\credentials" is used on Windows + #var.shared_credential_file: /etc/filebeat/aws_credentials + # Profile name for aws credential + # If not set the default profile is used #var.credential_profile_name: fb-aws #-------------------------------- Azure Module -------------------------------- @@ -1654,9 +1678,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # List of root certificates for HTTPS server verifications #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] @@ -1746,9 +1770,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -1919,9 +1943,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Certificate for SSL client authentication #ssl.certificate: "/etc/pki/client/cert.pem" @@ -2031,9 +2055,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -2256,7 +2280,7 @@ setup.template.settings: #setup.ilm.pattern: "{now/d}-000001" # Set the lifecycle policy name. The default policy name is -# 'filebeat-%{[agent.version]}'. +# 'filebeat'. #setup.ilm.policy_name: "mypolicy" # The path to a JSON file that contains a lifecycle policy configuration. Used @@ -2300,9 +2324,9 @@ setup.kibana: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -2476,9 +2500,9 @@ logging.files: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -2506,6 +2530,14 @@ logging.files: #metrics.period: 10s #state.period: 1m +# The `monitoring.cloud.id` setting overwrites the `monitoring.elasticsearch.hosts` +# setting. You can find the value for this setting in the Elastic Cloud web UI. +#monitoring.cloud.id: + +# The `monitoring.cloud.auth` setting overwrites the `monitoring.elasticsearch.username` +# and `monitoring.elasticsearch.password` settings. The format is `:`. +#monitoring.cloud.auth: + #================================ HTTP Endpoint ====================================== # Each beat can expose internal metrics through a HTTP endpoint. For security # reasons the endpoint is disabled by default. This feature is currently experimental. diff --git a/x-pack/filebeat/module/aws/_meta/config.yml b/x-pack/filebeat/module/aws/_meta/config.yml index 98ab79d69f5..f069a6d3128 100644 --- a/x-pack/filebeat/module/aws/_meta/config.yml +++ b/x-pack/filebeat/module/aws/_meta/config.yml @@ -5,7 +5,13 @@ # AWS SQS queue url #var.queue_url: https://sqs.myregion.amazonaws.com/123456/myqueue + # Filename of AWS credential file + # If not set "$HOME/.aws/credentials" is used on Linux/Mac + # "%UserProfile%\.aws\credentials" is used on Windows + #var.shared_credential_file: /etc/filebeat/aws_credentials + # Profile name for aws credential + # If not set the default profile is used #var.credential_profile_name: fb-aws elb: @@ -14,7 +20,13 @@ # AWS SQS queue url #var.queue_url: https://sqs.myregion.amazonaws.com/123456/myqueue + # Filename of AWS credential file + # If not set "$HOME/.aws/credentials" is used on Linux/Mac + # "%UserProfile%\.aws\credentials" is used on Windows + #var.shared_credential_file: /etc/filebeat/aws_credentials + # Profile name for aws credential + # If not set the default profile is used #var.credential_profile_name: fb-aws vpcflow: @@ -23,7 +35,13 @@ # AWS SQS queue url #var.queue_url: https://sqs.myregion.amazonaws.com/123456/myqueue + # Filename of AWS credential file + # If not set "$HOME/.aws/credentials" is used on Linux/Mac + # "%UserProfile%\.aws\credentials" is used on Windows + #var.shared_credential_file: /etc/filebeat/aws_credentials + # Profile name for aws credential + # If not set the default profile is used #var.credential_profile_name: fb-aws cloudtrail: @@ -32,5 +50,11 @@ # AWS SQS queue url #var.queue_url: https://sqs.myregion.amazonaws.com/123456/myqueue + # Filename of AWS credential file + # If not set "$HOME/.aws/credentials" is used on Linux/Mac + # "%UserProfile%\.aws\credentials" is used on Windows + #var.shared_credential_file: /etc/filebeat/aws_credentials + # Profile name for aws credential + # If not set the default profile is used #var.credential_profile_name: fb-aws diff --git a/x-pack/filebeat/module/aws/_meta/docs.asciidoc b/x-pack/filebeat/module/aws/_meta/docs.asciidoc index f35c2e9e4d5..fcfa0956f2e 100644 --- a/x-pack/filebeat/module/aws/_meta/docs.asciidoc +++ b/x-pack/filebeat/module/aws/_meta/docs.asciidoc @@ -40,8 +40,14 @@ Example config: # AWS SQS queue url #var.queue_url: https://sqs.myregion.amazonaws.com/123456/myqueue + # Filename of AWS credential file + # If not set "$HOME/.aws/credentials" is used on Linux/Mac + # "%UserProfile%\.aws\credentials" is used on Windows + # var.shared_credential_file: /etc/filebeat/aws_credentials + # Profile name for aws credential - #var.credential_profile_name: fb-aws + # If not set the default profile is used + # var.credential_profile_name: fb-aws elb: enabled: false @@ -49,8 +55,14 @@ Example config: # AWS SQS queue url #var.queue_url: https://sqs.myregion.amazonaws.com/123456/myqueue + # Filename of AWS credential file + # If not set "$HOME/.aws/credentials" is used on Linux/Mac + # "%UserProfile%\.aws\credentials" is used on Windows + # var.shared_credential_file: /etc/filebeat/aws_credentials + # Profile name for aws credential - #var.credential_profile_name: fb-aws + # If not set the default profile is used + # var.credential_profile_name: fb-aws vpcflow: enabled: false @@ -58,8 +70,14 @@ Example config: # AWS SQS queue url #var.queue_url: https://sqs.myregion.amazonaws.com/123456/myqueue + # Filename of AWS credential file + # If not set "$HOME/.aws/credentials" is used on Linux/Mac + # "%UserProfile%\.aws\credentials" is used on Windows + # var.shared_credential_file: /etc/filebeat/aws_credentials + # Profile name for aws credential - #var.credential_profile_name: fb-aws + # If not set the default profile is used + # var.credential_profile_name: fb-aws cloudtrail: enabled: false @@ -67,14 +85,24 @@ Example config: # AWS SQS queue url #var.queue_url: https://sqs.myregion.amazonaws.com/123456/myqueue + # Filename of AWS credential file + # If not set "$HOME/.aws/credentials" is used on Linux/Mac + # "%UserProfile%\.aws\credentials" is used on Windows + # var.shared_credential_file: /etc/filebeat/aws_credentials + # Profile name for aws credential - #var.credential_profile_name: fb-aws + # If not set the default profile is used + # var.credential_profile_name: fb-aws ---- *`var.queue_url`*:: AWS SQS queue url. +*`var.shared_credential_file`*:: + +Filename of AWS credential file. + *`var.credential_profile_name`*:: AWS credential profile name. diff --git a/x-pack/filebeat/module/aws/cloudtrail/config/cloudtrail.yml b/x-pack/filebeat/module/aws/cloudtrail/config/cloudtrail.yml index 2b1c3b8551b..6b340543a86 100644 --- a/x-pack/filebeat/module/aws/cloudtrail/config/cloudtrail.yml +++ b/x-pack/filebeat/module/aws/cloudtrail/config/cloudtrail.yml @@ -2,9 +2,17 @@ type: s3 queue_url: {{ .queue_url }} -credential_profile_name: {{ .credential_profile_name }} expand_event_list_from_field: Records +{{ if .credential_profile_name }} +credential_profile_name: {{ .credential_profile_name }} +{{ end }} + +{{ if .shared_credential_file }} +shared_credential_file: {{ .shared_credential_file }} +{{ end }} + + {{ else if eq .input "file" }} type: log diff --git a/x-pack/filebeat/module/aws/cloudtrail/manifest.yml b/x-pack/filebeat/module/aws/cloudtrail/manifest.yml index 915da46a368..4865624045e 100644 --- a/x-pack/filebeat/module/aws/cloudtrail/manifest.yml +++ b/x-pack/filebeat/module/aws/cloudtrail/manifest.yml @@ -3,6 +3,8 @@ module_version: 1.0 var: - name: input default: s3 + - name: shared_credential_file + - name: credential_profile_name ingest_pipeline: ingest/pipeline.yml input: config/cloudtrail.yml diff --git a/x-pack/filebeat/module/aws/elb/config/s3.yml b/x-pack/filebeat/module/aws/elb/config/s3.yml index 4bc46921c20..c4c151708b9 100644 --- a/x-pack/filebeat/module/aws/elb/config/s3.yml +++ b/x-pack/filebeat/module/aws/elb/config/s3.yml @@ -1,3 +1,10 @@ type: s3 queue_url: {{ .queue_url }} + +{{ if .credential_profile_name }} credential_profile_name: {{ .credential_profile_name }} +{{ end }} + +{{ if .shared_credential_file }} +shared_credential_file: {{ .shared_credential_file }} +{{ end }} diff --git a/x-pack/filebeat/module/aws/elb/manifest.yml b/x-pack/filebeat/module/aws/elb/manifest.yml index d39eacc5847..ca83ac2a315 100644 --- a/x-pack/filebeat/module/aws/elb/manifest.yml +++ b/x-pack/filebeat/module/aws/elb/manifest.yml @@ -3,6 +3,8 @@ module_version: 1.0 var: - name: input default: s3 + - name: shared_credential_file + - name: credential_profile_name ingest_pipeline: ingest/pipeline.yml input: config/{{.input}}.yml diff --git a/x-pack/filebeat/module/aws/s3access/config/s3.yml b/x-pack/filebeat/module/aws/s3access/config/s3.yml index 4bc46921c20..c4c151708b9 100644 --- a/x-pack/filebeat/module/aws/s3access/config/s3.yml +++ b/x-pack/filebeat/module/aws/s3access/config/s3.yml @@ -1,3 +1,10 @@ type: s3 queue_url: {{ .queue_url }} + +{{ if .credential_profile_name }} credential_profile_name: {{ .credential_profile_name }} +{{ end }} + +{{ if .shared_credential_file }} +shared_credential_file: {{ .shared_credential_file }} +{{ end }} diff --git a/x-pack/filebeat/module/aws/s3access/manifest.yml b/x-pack/filebeat/module/aws/s3access/manifest.yml index 7eea71864a2..20c0ce4efc7 100644 --- a/x-pack/filebeat/module/aws/s3access/manifest.yml +++ b/x-pack/filebeat/module/aws/s3access/manifest.yml @@ -3,6 +3,8 @@ module_version: 1.0 var: - name: input default: s3 + - name: shared_credential_file + - name: credential_profile_name ingest_pipeline: ingest/pipeline.yml input: config/{{.input}}.yml diff --git a/x-pack/filebeat/module/aws/vpcflow/config/input.yml b/x-pack/filebeat/module/aws/vpcflow/config/input.yml index 432abff6d37..250ce449e55 100644 --- a/x-pack/filebeat/module/aws/vpcflow/config/input.yml +++ b/x-pack/filebeat/module/aws/vpcflow/config/input.yml @@ -2,7 +2,14 @@ type: s3 queue_url: {{ .queue_url }} + +{{ if .credential_profile_name }} credential_profile_name: {{ .credential_profile_name }} +{{ end }} + +{{ if .shared_credential_file }} +shared_credential_file: {{ .shared_credential_file }} +{{ end }} {{ else if eq .input "file" }} diff --git a/x-pack/filebeat/module/aws/vpcflow/manifest.yml b/x-pack/filebeat/module/aws/vpcflow/manifest.yml index ce86747f865..9e047a606eb 100644 --- a/x-pack/filebeat/module/aws/vpcflow/manifest.yml +++ b/x-pack/filebeat/module/aws/vpcflow/manifest.yml @@ -3,6 +3,8 @@ module_version: 1.0 var: - name: input default: s3 + - name: shared_credential_file + - name: credential_profile_name ingest_pipeline: ingest/pipeline.yml input: config/input.yml diff --git a/x-pack/filebeat/module/googlecloud/audit/config/pipeline.js b/x-pack/filebeat/module/googlecloud/audit/config/pipeline.js index 93d8b8648f1..65819ff6a92 100644 --- a/x-pack/filebeat/module/googlecloud/audit/config/pipeline.js +++ b/x-pack/filebeat/module/googlecloud/audit/config/pipeline.js @@ -118,8 +118,30 @@ function Audit(keep_original_message) { var RenameNestedFields = function(evt) { var arr = evt.Get("googlecloud.audit.authorization_info"); for (var i = 0; i < arr.length; i++) { - arr[i].resource_attributes = arr[i].resourceAttributes; - delete arr[i].resourceAttributes; + arr[i].resource_attributes = arr[i].resourceAttributes; + delete arr[i].resourceAttributes; + } + }; + + // Set event.outcome based on authentication_info and status. + var setEventOutcome = function(evt) { + if (evt.Get("googlecloud.audit.status.code") == null) { + var authorization_info = evt.Get("googlecloud.audit.authorization_info"); + if (authorization_info.length === 1) { + if (authorization_info[0].granted == null) { + evt.Put("event.outcome", "unknown"); + } else if (authorization_info[0].granted === true) { + evt.Put("event.outcome", "success"); + } else { + evt.Put("event.outcome", "failure"); + } + } else { + evt.Put("event.outcome", "unknown"); + } + } else if (evt.Get("googlecloud.audit.status.code") === 0) { + evt.Put("event.outcome", "success"); + } else { + evt.Put("event.outcome", "failure"); } }; @@ -135,6 +157,7 @@ function Audit(keep_original_message) { .Add(copyFields) .Add(dropExtraFields) .Add(RenameNestedFields) + .Add(setEventOutcome) .Build(); return { diff --git a/x-pack/filebeat/module/googlecloud/audit/test/audit-log-entries.json.log b/x-pack/filebeat/module/googlecloud/audit/test/audit-log-entries.json.log index e42e9106287..2120a297a5f 100644 --- a/x-pack/filebeat/module/googlecloud/audit/test/audit-log-entries.json.log +++ b/x-pack/filebeat/module/googlecloud/audit/test/audit-log-entries.json.log @@ -1,3 +1,4 @@ {"insertId":"-uihnmjctwo","logName":"projects/elastic-beats/logs/cloudaudit.googleapis.com%2Fdata_access","protoPayload":{"@type":"type.googleapis.com/google.cloud.audit.AuditLog","authenticationInfo":{"principalEmail":"xxx@xxx.xxx"},"authorizationInfo":[{"granted":true,"permission":"resourcemanager.projects.get","resource":"projects/elastic-beats","resourceAttributes":{}}],"methodName":"GetResourceBillingInfo","request":{"@type":"type.googleapis.com/google.internal.cloudbilling.billingaccount.v1.GetResourceBillingInfoRequest","resourceName":"projects/189716325846"},"requestMetadata":{"callerIp":"192.168.1.1","destinationAttributes":{},"requestAttributes":{}},"resourceName":"projects/elastic-beats","serviceName":"cloudbilling.googleapis.com","status":{}},"receiveTimestamp":"2019-12-19T00:49:36.313482371Z","resource":{"labels":{"project_id":"elastic-beats"},"type":"project"},"severity":"INFO","timestamp":"2019-12-19T00:49:36.086Z"} -{"insertId":"-h6onuze1h7dg","logName":"projects/elastic-beats/logs/cloudaudit.googleapis.com%2Fdata_access","protoPayload":{"@type":"type.googleapis.com/google.cloud.audit.AuditLog","authenticationInfo":{"principalEmail":"xxx@xxx.xxx"},"authorizationInfo":[{"granted":true,"permission":"compute.machineTypes.list","resourceAttributes":{"name":"projects/elastic-beats","service":"resourcemanager","type":"resourcemanager.projects"}}],"methodName":"beta.compute.machineTypes.aggregatedList","numResponseItems":"71","request":{"@type":"type.googleapis.com/compute.machineTypes.aggregatedList"},"requestMetadata":{"callerIp":"192.168.1.1","callerSuppliedUserAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:71.0) Gecko/20100101 Firefox/71.0,gzip(gfe),gzip(gfe)","destinationAttributes":{},"requestAttributes":{"auth":{},"time":"2019-12-19T00:45:51.711Z"}},"resourceLocation":{"currentLocations":["global"]},"resourceName":"projects/elastic-beats/global/machineTypes","serviceName":"compute.googleapis.com"},"receiveTimestamp":"2019-12-19T00:45:52.367887078Z","resource":{"labels":{"location":"global","method":"compute.machineTypes.aggregatedList","project_id":"elastic-beats","service":"compute.googleapis.com","version":"beta"},"type":"api"},"severity":"INFO","timestamp":"2019-12-19T00:45:51.228Z"} +{"insertId":"-h6onuze1h7dg","logName":"projects/elastic-beats/logs/cloudaudit.googleapis.com%2Fdata_access","protoPayload":{"@type":"type.googleapis.com/google.cloud.audit.AuditLog","authenticationInfo":{"principalEmail":"xxx@xxx.xxx"},"authorizationInfo":[{"granted":false,"permission":"compute.machineTypes.list","resourceAttributes":{"name":"projects/elastic-beats","service":"resourcemanager","type":"resourcemanager.projects"}}],"methodName":"beta.compute.machineTypes.aggregatedList","numResponseItems":"71","request":{"@type":"type.googleapis.com/compute.machineTypes.aggregatedList"},"requestMetadata":{"callerIp":"192.168.1.1","callerSuppliedUserAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:71.0) Gecko/20100101 Firefox/71.0,gzip(gfe),gzip(gfe)","destinationAttributes":{},"requestAttributes":{"auth":{},"time":"2019-12-19T00:45:51.711Z"}},"resourceLocation":{"currentLocations":["global"]},"resourceName":"projects/elastic-beats/global/machineTypes","serviceName":"compute.googleapis.com"},"receiveTimestamp":"2019-12-19T00:45:52.367887078Z","resource":{"labels":{"location":"global","method":"compute.machineTypes.aggregatedList","project_id":"elastic-beats","service":"compute.googleapis.com","version":"beta"},"type":"api"},"severity":"INFO","timestamp":"2019-12-19T00:45:51.228Z"} {"insertId":"yonau2dg2zi","logName":"projects/elastic-beats/logs/cloudaudit.googleapis.com%2Fdata_access","protoPayload":{"@type":"type.googleapis.com/google.cloud.audit.AuditLog","authenticationInfo":{"principalEmail":"xxx@xxx.xxx"},"authorizationInfo":[{"granted":true,"permission":"compute.instances.list","resourceAttributes":{"name":"projects/elastic-beats","service":"resourcemanager","type":"resourcemanager.projects"}}],"methodName":"beta.compute.instances.aggregatedList","numResponseItems":"61","request":{"@type":"type.googleapis.com/compute.instances.aggregatedList"},"requestMetadata":{"callerIp":"192.168.1.1","callerSuppliedUserAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:71.0) Gecko/20100101 Firefox/71.0,gzip(gfe),gzip(gfe)","destinationAttributes":{},"requestAttributes":{"auth":{},"time":"2019-12-19T00:44:25.198Z"}},"resourceLocation":{"currentLocations":["global"]},"resourceName":"projects/elastic-beats/global/instances","serviceName":"compute.googleapis.com"},"receiveTimestamp":"2019-12-19T00:44:25.262379373Z","resource":{"labels":{"location":"global","method":"compute.instances.aggregatedList","project_id":"elastic-beats","service":"compute.googleapis.com","version":"beta"},"type":"api"},"severity":"INFO","timestamp":"2019-12-19T00:44:25.051Z"} +{"insertId":"yonau3dc2zi","logName":"projects/elastic-beats/logs/cloudaudit.googleapis.com%2Fdata_access","protoPayload":{"@type":"type.googleapis.com/google.cloud.audit.AuditLog","authenticationInfo":{"principalEmail":"xxx@xxx.xxx"},"authorizationInfo":[{"permission":"compute.instances.list","resourceAttributes":{"name":"projects/elastic-beats","service":"resourcemanager","type":"resourcemanager.projects"}}],"methodName":"beta.compute.instances.aggregatedList","numResponseItems":"61","request":{"@type":"type.googleapis.com/compute.instances.aggregatedList"},"requestMetadata":{"callerIp":"192.168.1.1","callerSuppliedUserAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:71.0) Gecko/20100101 Firefox/71.0,gzip(gfe),gzip(gfe)","destinationAttributes":{},"requestAttributes":{"auth":{},"time":"2019-12-19T00:44:25.198Z"}},"resourceLocation":{"currentLocations":["global"]},"resourceName":"projects/elastic-beats/global/instances","serviceName":"compute.googleapis.com","status":{"code":7,"message":"PERMISSION_DENIED"}},"receiveTimestamp":"2019-12-19T00:44:25.262379373Z","resource":{"labels":{"location":"global","method":"compute.instances.aggregatedList","project_id":"elastic-beats","service":"compute.googleapis.com","version":"beta"},"type":"api"},"severity":"INFO","timestamp":"2019-12-19T00:44:25.051Z"} diff --git a/x-pack/filebeat/module/googlecloud/audit/test/audit-log-entries.json.log-expected.json b/x-pack/filebeat/module/googlecloud/audit/test/audit-log-entries.json.log-expected.json index d303ad1076c..37ef7275861 100644 --- a/x-pack/filebeat/module/googlecloud/audit/test/audit-log-entries.json.log-expected.json +++ b/x-pack/filebeat/module/googlecloud/audit/test/audit-log-entries.json.log-expected.json @@ -4,6 +4,7 @@ "cloud.project.id": "elastic-beats", "event.dataset": "googlecloud.audit", "event.module": "googlecloud", + "event.outcome": "success", "fileset.name": "audit", "googlecloud.audit.authentication_info.principal_email": "xxx@xxx.xxx", "googlecloud.audit.authorization_info": [ @@ -34,11 +35,12 @@ "cloud.project.id": "elastic-beats", "event.dataset": "googlecloud.audit", "event.module": "googlecloud", + "event.outcome": "failure", "fileset.name": "audit", "googlecloud.audit.authentication_info.principal_email": "xxx@xxx.xxx", "googlecloud.audit.authorization_info": [ { - "granted": true, + "granted": false, "permission": "compute.machineTypes.list", "resource_attributes": { "name": "projects/elastic-beats", @@ -78,6 +80,7 @@ "cloud.project.id": "elastic-beats", "event.dataset": "googlecloud.audit", "event.module": "googlecloud", + "event.outcome": "success", "fileset.name": "audit", "googlecloud.audit.authentication_info.principal_email": "xxx@xxx.xxx", "googlecloud.audit.authorization_info": [ @@ -104,7 +107,53 @@ "googlecloud.audit.type": "type.googleapis.com/google.cloud.audit.AuditLog", "input.type": "log", "log.logger": "projects/elastic-beats/logs/cloudaudit.googleapis.com%2Fdata_access", - "log.offset": 2251, + "log.offset": 2252, + "service.name": "compute.googleapis.com", + "service.type": "googlecloud", + "source.ip": "192.168.1.1", + "user.email": "xxx@xxx.xxx", + "user_agent.device.name": "Other", + "user_agent.name": "Firefox", + "user_agent.original": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:71.0) Gecko/20100101 Firefox/71.0,gzip(gfe),gzip(gfe)", + "user_agent.os.full": "Mac OS X 10.15", + "user_agent.os.name": "Mac OS X", + "user_agent.os.version": "10.15", + "user_agent.version": "71.0." + }, + { + "@timestamp": "2019-12-19T00:44:25.051Z", + "cloud.project.id": "elastic-beats", + "event.dataset": "googlecloud.audit", + "event.module": "googlecloud", + "event.outcome": "failure", + "fileset.name": "audit", + "googlecloud.audit.authentication_info.principal_email": "xxx@xxx.xxx", + "googlecloud.audit.authorization_info": [ + { + "permission": "compute.instances.list", + "resource_attributes": { + "name": "projects/elastic-beats", + "service": "resourcemanager", + "type": "resourcemanager.projects" + } + } + ], + "googlecloud.audit.method_name": "beta.compute.instances.aggregatedList", + "googlecloud.audit.num_response_items": 61, + "googlecloud.audit.request.proto_name": "type.googleapis.com/compute.instances.aggregatedList", + "googlecloud.audit.request_metadata.caller_ip": "192.168.1.1", + "googlecloud.audit.request_metadata.caller_supplied_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:71.0) Gecko/20100101 Firefox/71.0,gzip(gfe),gzip(gfe)", + "googlecloud.audit.resource_location.current_locations": [ + "global" + ], + "googlecloud.audit.resource_name": "projects/elastic-beats/global/instances", + "googlecloud.audit.service_name": "compute.googleapis.com", + "googlecloud.audit.status.code": 7, + "googlecloud.audit.status.message": "PERMISSION_DENIED", + "googlecloud.audit.type": "type.googleapis.com/google.cloud.audit.AuditLog", + "input.type": "log", + "log.logger": "projects/elastic-beats/logs/cloudaudit.googleapis.com%2Fdata_access", + "log.offset": 3541, "service.name": "compute.googleapis.com", "service.type": "googlecloud", "source.ip": "192.168.1.1", diff --git a/x-pack/filebeat/modules.d/aws.yml.disabled b/x-pack/filebeat/modules.d/aws.yml.disabled index f43bed2eb56..ee4fb63a04c 100644 --- a/x-pack/filebeat/modules.d/aws.yml.disabled +++ b/x-pack/filebeat/modules.d/aws.yml.disabled @@ -8,7 +8,13 @@ # AWS SQS queue url #var.queue_url: https://sqs.myregion.amazonaws.com/123456/myqueue + # Filename of AWS credential file + # If not set "$HOME/.aws/credentials" is used on Linux/Mac + # "%UserProfile%\.aws\credentials" is used on Windows + #var.shared_credential_file: /etc/filebeat/aws_credentials + # Profile name for aws credential + # If not set the default profile is used #var.credential_profile_name: fb-aws elb: @@ -17,7 +23,13 @@ # AWS SQS queue url #var.queue_url: https://sqs.myregion.amazonaws.com/123456/myqueue + # Filename of AWS credential file + # If not set "$HOME/.aws/credentials" is used on Linux/Mac + # "%UserProfile%\.aws\credentials" is used on Windows + #var.shared_credential_file: /etc/filebeat/aws_credentials + # Profile name for aws credential + # If not set the default profile is used #var.credential_profile_name: fb-aws vpcflow: @@ -26,7 +38,13 @@ # AWS SQS queue url #var.queue_url: https://sqs.myregion.amazonaws.com/123456/myqueue + # Filename of AWS credential file + # If not set "$HOME/.aws/credentials" is used on Linux/Mac + # "%UserProfile%\.aws\credentials" is used on Windows + #var.shared_credential_file: /etc/filebeat/aws_credentials + # Profile name for aws credential + # If not set the default profile is used #var.credential_profile_name: fb-aws cloudtrail: @@ -35,5 +53,11 @@ # AWS SQS queue url #var.queue_url: https://sqs.myregion.amazonaws.com/123456/myqueue + # Filename of AWS credential file + # If not set "$HOME/.aws/credentials" is used on Linux/Mac + # "%UserProfile%\.aws\credentials" is used on Windows + #var.shared_credential_file: /etc/filebeat/aws_credentials + # Profile name for aws credential + # If not set the default profile is used #var.credential_profile_name: fb-aws diff --git a/x-pack/functionbeat/functionbeat.reference.yml b/x-pack/functionbeat/functionbeat.reference.yml index e04b3de57b6..461df86d12f 100644 --- a/x-pack/functionbeat/functionbeat.reference.yml +++ b/x-pack/functionbeat/functionbeat.reference.yml @@ -751,9 +751,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # List of root certificates for HTTPS server verifications #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] @@ -843,9 +843,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -1036,7 +1036,7 @@ setup.template.settings: #setup.ilm.pattern: "{now/d}-000001" # Set the lifecycle policy name. The default policy name is -# 'functionbeat-%{[agent.version]}'. +# 'functionbeat'. #setup.ilm.policy_name: "mypolicy" # The path to a JSON file that contains a lifecycle policy configuration. Used @@ -1080,9 +1080,9 @@ setup.kibana: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -1256,9 +1256,9 @@ logging.files: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -1286,6 +1286,14 @@ logging.files: #metrics.period: 10s #state.period: 1m +# The `monitoring.cloud.id` setting overwrites the `monitoring.elasticsearch.hosts` +# setting. You can find the value for this setting in the Elastic Cloud web UI. +#monitoring.cloud.id: + +# The `monitoring.cloud.auth` setting overwrites the `monitoring.elasticsearch.username` +# and `monitoring.elasticsearch.password` settings. The format is `:`. +#monitoring.cloud.auth: + #================================ HTTP Endpoint ====================================== # Each beat can expose internal metrics through a HTTP endpoint. For security # reasons the endpoint is disabled by default. This feature is currently experimental. diff --git a/x-pack/functionbeat/magefile.go b/x-pack/functionbeat/magefile.go index ab3432c720a..89e497d0f4f 100644 --- a/x-pack/functionbeat/magefile.go +++ b/x-pack/functionbeat/magefile.go @@ -60,6 +60,14 @@ func Build() error { params.InputFiles = []string{inputFiles} params.Name = devtools.BeatName + "-" + provider.Name params.OutputDir = filepath.Join("provider", provider.Name) + params.CGO = false + params.Env = make(map[string]string) + if provider.GOOS != "" { + params.Env["GOOS"] = provider.GOOS + } + if provider.GOARCH != "" { + params.Env["GOARCH"] = provider.GOARCH + } err := devtools.Build(params) if err != nil { return err diff --git a/x-pack/functionbeat/scripts/mage/providers.go b/x-pack/functionbeat/scripts/mage/providers.go index c465abc373f..538fcdda071 100644 --- a/x-pack/functionbeat/scripts/mage/providers.go +++ b/x-pack/functionbeat/scripts/mage/providers.go @@ -12,7 +12,7 @@ import ( var ( availableProviders = []ProviderDetails{ - {Name: "aws", Buildable: true}, + {Name: "aws", Buildable: true, GOOS: "linux", GOARCH: "amd64"}, {Name: "gcp", Buildable: false}, } ) @@ -21,6 +21,8 @@ var ( type ProviderDetails struct { Name string Buildable bool + GOOS string + GOARCH string } // SelectedProviders is the list of selected providers diff --git a/x-pack/metricbeat/include/list.go b/x-pack/metricbeat/include/list.go index f1d2485b128..e1e6943c058 100644 --- a/x-pack/metricbeat/include/list.go +++ b/x-pack/metricbeat/include/list.go @@ -29,6 +29,8 @@ import ( _ "github.com/elastic/beats/x-pack/metricbeat/module/googlecloud" _ "github.com/elastic/beats/x-pack/metricbeat/module/googlecloud/stackdriver" _ "github.com/elastic/beats/x-pack/metricbeat/module/ibmmq" + _ "github.com/elastic/beats/x-pack/metricbeat/module/istio" + _ "github.com/elastic/beats/x-pack/metricbeat/module/istio/mesh" _ "github.com/elastic/beats/x-pack/metricbeat/module/mssql" _ "github.com/elastic/beats/x-pack/metricbeat/module/mssql/performance" _ "github.com/elastic/beats/x-pack/metricbeat/module/mssql/transaction_log" diff --git a/x-pack/metricbeat/metricbeat.reference.yml b/x-pack/metricbeat/metricbeat.reference.yml index bf24255b4e3..595fda51dba 100644 --- a/x-pack/metricbeat/metricbeat.reference.yml +++ b/x-pack/metricbeat/metricbeat.reference.yml @@ -73,12 +73,13 @@ metricbeat.modules: #- fsstat # File system summary metrics #- raid # Raid #- socket # Sockets and connection info (linux only) + #- service # systemd service information enabled: true period: 10s processes: ['.*'] # Configure the metric types that are included by these metricsets. - cpu.metrics: ["percentages"] # The other available options are normalized_percentages and ticks. + cpu.metrics: ["percentages","normalized_percentages"] # The other available option is ticks. core.metrics: ["percentages"] # The other available option is ticks. # A list of filesystem types to ignore. The filesystem metricset will not @@ -131,6 +132,9 @@ metricbeat.modules: # Diskio configurations #diskio.include_devices: [] + # Filter systemd services by status or sub-status + #service.state_filter: [] + #------------------------------- Activemq Module ------------------------------- - module: activemq metricsets: ['broker', 'queue', 'topic'] @@ -533,6 +537,12 @@ metricbeat.modules: } } +#-------------------------------- Istio Module -------------------------------- +- module: istio + metricsets: ["mesh"] + period: 10s + hosts: ["localhost:42422"] + #------------------------------- Jolokia Module ------------------------------- - module: jolokia #metricsets: ["jmx"] @@ -965,10 +975,9 @@ metricbeat.modules: metricsets: - query period: 10s - hosts: ["localhost"] + hosts: ["user=myuser password=mypassword dbname=mydb sslmode=disable"] driver: "postgres" - datasource: "user=myuser password=mypassword dbname=mydb sslmode=disable" sql_query: "select now()" @@ -1416,9 +1425,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # List of root certificates for HTTPS server verifications #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] @@ -1508,9 +1517,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -1681,9 +1690,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Certificate for SSL client authentication #ssl.certificate: "/etc/pki/client/cert.pem" @@ -1793,9 +1802,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -2018,7 +2027,7 @@ setup.template.settings: #setup.ilm.pattern: "{now/d}-000001" # Set the lifecycle policy name. The default policy name is -# 'metricbeat-%{[agent.version]}'. +# 'metricbeat'. #setup.ilm.policy_name: "mypolicy" # The path to a JSON file that contains a lifecycle policy configuration. Used @@ -2062,9 +2071,9 @@ setup.kibana: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -2238,9 +2247,9 @@ logging.files: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -2268,6 +2277,14 @@ logging.files: #metrics.period: 10s #state.period: 1m +# The `monitoring.cloud.id` setting overwrites the `monitoring.elasticsearch.hosts` +# setting. You can find the value for this setting in the Elastic Cloud web UI. +#monitoring.cloud.id: + +# The `monitoring.cloud.auth` setting overwrites the `monitoring.elasticsearch.username` +# and `monitoring.elasticsearch.password` settings. The format is `:`. +#monitoring.cloud.auth: + #================================ HTTP Endpoint ====================================== # Each beat can expose internal metrics through a HTTP endpoint. For security # reasons the endpoint is disabled by default. This feature is currently experimental. diff --git a/x-pack/metricbeat/module/activemq/test_activemq.py b/x-pack/metricbeat/module/activemq/test_activemq.py index b705bb96bdc..4b643f984a2 100644 --- a/x-pack/metricbeat/module/activemq/test_activemq.py +++ b/x-pack/metricbeat/module/activemq/test_activemq.py @@ -24,6 +24,9 @@ def get_activemq_module_config(self, metricset): 'password': 'admin' } + def get_hosts(self): + return [self.compose_host(port='8161/tcp')] + def get_stomp_host_port(self): host_port = self.compose_host(port='61613/tcp') s = host_port.split(':') diff --git a/x-pack/metricbeat/module/aws/_meta/fields.yml b/x-pack/metricbeat/module/aws/_meta/fields.yml index a0929371857..30b790cbab6 100644 --- a/x-pack/metricbeat/module/aws/_meta/fields.yml +++ b/x-pack/metricbeat/module/aws/_meta/fields.yml @@ -28,9 +28,9 @@ object_type_mapping_type: "*" description: > Metric dimensions. - - name: aws.*.metrics.*.* - type: object - object_type: double - object_type_mapping_type: "*" - description: > - Metrics that returned from Cloudwatch API query. + - name: '*.metrics.*.*' + type: object + object_type: double + object_type_mapping_type: "*" + description: > + Metrics that returned from Cloudwatch API query. diff --git a/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-billing-overview.json b/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-billing-overview.json index 7fb9ee9b886..be1b2935b02 100644 --- a/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-billing-overview.json +++ b/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-billing-overview.json @@ -32,7 +32,7 @@ "panelIndex": "89dccfe8-a25e-44ea-afdb-ff01ab1f05d6", "panelRefName": "panel_0", "title": "AWS Account Filter", - "version": "7.5.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -48,7 +48,7 @@ "panelIndex": "26670498-b079-4447-bbc8-e4ca8215898c", "panelRefName": "panel_1", "title": "Estimated Billing Chart", - "version": "7.5.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -56,15 +56,15 @@ }, "gridData": { "h": 11, - "i": "04159643-33c0-4f01-80f1-fb8d212ed959", + "i": "221aab02-2747-4d84-9dde-028ccd51bdce", "w": 16, "x": 0, "y": 5 }, - "panelIndex": "04159643-33c0-4f01-80f1-fb8d212ed959", + "panelIndex": "221aab02-2747-4d84-9dde-028ccd51bdce", "panelRefName": "panel_2", "title": "Total Estimated Charges", - "version": "7.5.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -80,7 +80,7 @@ "panelIndex": "21e91e6b-0ff0-42ba-9132-6f30c5c6bbb7", "panelRefName": "panel_3", "title": "Top 5 Estimated Billing Per Service Name", - "version": "7.5.0" + "version": "7.3.0" } ], "timeRestore": false, @@ -114,8 +114,8 @@ } ], "type": "dashboard", - "updated_at": "2019-12-02T18:54:47.255Z", - "version": "WzU1NywyXQ==" + "updated_at": "2020-01-17T15:11:20.337Z", + "version": "WzY2MiwxXQ==" }, { "attributes": { @@ -140,7 +140,7 @@ "fieldName": "cloud.account.name", "id": "1549397251041", "indexPatternRefName": "control_0_index_pattern", - "label": "AWS account", + "label": "account name", "options": { "dynamicOptions": true, "multiselect": true, @@ -172,8 +172,8 @@ } ], "type": "visualization", - "updated_at": "2019-12-02T18:50:52.450Z", - "version": "WzU1MywyXQ==" + "updated_at": "2020-01-17T14:43:10.917Z", + "version": "WzE1NywxXQ==" }, { "attributes": { @@ -295,8 +295,8 @@ } ], "type": "visualization", - "updated_at": "2019-12-02T18:53:50.818Z", - "version": "WzU1NSwyXQ==" + "updated_at": "2020-01-17T14:43:00.631Z", + "version": "WzU0LDFd" }, { "attributes": { @@ -329,7 +329,7 @@ "id": "ebb52700-1531-11ea-961e-c1db9cc6166e" } ], - "default_index_pattern": "filebeat-*", + "default_index_pattern": "metricbeat-*", "default_timefield": "@timestamp", "drop_last_bucket": 1, "gauge_color_rules": [ @@ -352,7 +352,7 @@ "fill": 0.5, "filter": { "language": "kuery", - "query": "aws.dimensions.ServiceName :* " + "query": "not aws.dimensions.ServiceName : * " }, "formatter": "number", "id": "61ca57f1-469d-11e7-af02-69e470af7417", @@ -365,16 +365,20 @@ "type": "sum" } ], + "override_index_pattern": 1, "point_size": 1, "separate_axis": 0, + "series_drop_last_bucket": 0, + "series_interval": "12h", "split_mode": "filter", "stacked": "none", + "time_range_mode": "entire_time_range", "value_template": "${{value}}" } ], "show_grid": 1, "show_legend": 1, - "time_field": null, + "time_field": "@timestamp", "type": "metric" }, "title": "Total Estimated Charges [Metricbeat AWS]", @@ -387,8 +391,8 @@ }, "references": [], "type": "visualization", - "updated_at": "2019-12-02T18:35:29.434Z", - "version": "WzU0NywyXQ==" + "updated_at": "2020-01-17T15:10:12.013Z", + "version": "WzY1OSwxXQ==" }, { "attributes": { @@ -472,9 +476,9 @@ }, "references": [], "type": "visualization", - "updated_at": "2019-12-02T18:49:11.978Z", - "version": "WzU1MSwyXQ==" + "updated_at": "2020-01-17T14:43:00.631Z", + "version": "WzU2LDFd" } ], - "version": "7.5.0" + "version": "7.3.0" } diff --git a/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-dynamodb-overview.json b/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-dynamodb-overview.json index 7f58be85cea..c414bc2ea05 100644 --- a/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-dynamodb-overview.json +++ b/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-dynamodb-overview.json @@ -29,7 +29,7 @@ }, "panelIndex": "9642fcd0-464b-46ea-815c-cd2d9efc056d", "panelRefName": "panel_0", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -42,7 +42,7 @@ }, "panelIndex": "03807c37-c9dc-4b41-80ce-e28a13eb66e2", "panelRefName": "panel_1", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -55,7 +55,7 @@ }, "panelIndex": "18810035-5e91-409a-98d7-c03166e1f9b3", "panelRefName": "panel_2", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -68,7 +68,7 @@ }, "panelIndex": "60e6e6e4-3237-430e-80fc-63fe9b718a7e", "panelRefName": "panel_3", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -81,7 +81,7 @@ }, "panelIndex": "5e5d6509-2889-4383-bef4-9c2da0e759c6", "panelRefName": "panel_4", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -94,7 +94,7 @@ }, "panelIndex": "2db371a7-20c5-460a-a2f7-06b5b03d7b34", "panelRefName": "panel_5", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -107,7 +107,7 @@ }, "panelIndex": "1cd72292-ecba-4008-bb3c-e76c7fb6b4f4", "panelRefName": "panel_6", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -120,7 +120,7 @@ }, "panelIndex": "cea56791-2602-4079-977b-7d088727872c", "panelRefName": "panel_7", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -133,7 +133,7 @@ }, "panelIndex": "fe509a4d-700b-4092-9aae-ce14e8de103e", "panelRefName": "panel_8", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -146,7 +146,7 @@ }, "panelIndex": "3d6b1fa0-746f-40ed-8fcc-ae89013f632b", "panelRefName": "panel_9", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -159,7 +159,7 @@ }, "panelIndex": "0f9a5223-3c63-405c-a5c4-ea15416bad4a", "panelRefName": "panel_10", - "version": "7.4.0" + "version": "7.3.0" } ], "timeRestore": false, @@ -1852,5 +1852,5 @@ "version": "WzUxMzMsMV0=" } ], - "version": "7.4.0" + "version": "7.3.0" } diff --git a/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-ebs-overview.json b/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-ebs-overview.json index 4ff1c55910b..8c0ff27c60f 100644 --- a/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-ebs-overview.json +++ b/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-ebs-overview.json @@ -30,7 +30,7 @@ "panelIndex": "1", "panelRefName": "panel_0", "title": "Volume Write Ops", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -44,7 +44,7 @@ "panelIndex": "2", "panelRefName": "panel_1", "title": "Volume Read Ops", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -58,7 +58,7 @@ "panelIndex": "3", "panelRefName": "panel_2", "title": "Volume Write Bytes", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -72,7 +72,7 @@ "panelIndex": "4", "panelRefName": "panel_3", "title": "Volume Read Bytes", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -86,7 +86,7 @@ "panelIndex": "5", "panelRefName": "panel_4", "title": "Volume Queue Length", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -100,7 +100,7 @@ "panelIndex": "6", "panelRefName": "panel_5", "title": "Volume Total Write Time", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -114,7 +114,7 @@ "panelIndex": "7", "panelRefName": "panel_6", "title": "Volume Total Read Time", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -128,7 +128,7 @@ "panelIndex": "8", "panelRefName": "panel_7", "title": "Volume Idle Time", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -142,7 +142,7 @@ "panelIndex": "9", "panelRefName": "panel_8", "title": "EBS Volume ID Filter", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -155,7 +155,7 @@ }, "panelIndex": "10", "panelRefName": "panel_9", - "version": "7.4.0" + "version": "7.3.0" } ], "timeRestore": false, @@ -916,5 +916,5 @@ "version": "WzU2NTQsN10=" } ], - "version": "7.4.0" + "version": "7.3.0" } diff --git a/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-elb-overview.json b/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-elb-overview.json index cadca10e4db..6164c11bed4 100644 --- a/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-elb-overview.json +++ b/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-elb-overview.json @@ -30,7 +30,7 @@ "panelIndex": "2", "panelRefName": "panel_0", "title": "HTTP 5XX Errors", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -44,7 +44,7 @@ "panelIndex": "3", "panelRefName": "panel_1", "title": "Request Count", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -58,7 +58,7 @@ "panelIndex": "4", "panelRefName": "panel_2", "title": "Unhealthy Host Count", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -72,7 +72,7 @@ "panelIndex": "5", "panelRefName": "panel_3", "title": "Healthy Host Count", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -86,7 +86,7 @@ "panelIndex": "6", "panelRefName": "panel_4", "title": "Latency in Seconds", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -100,7 +100,7 @@ "panelIndex": "7", "panelRefName": "panel_5", "title": "HTTP Backend 4XX Errors", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -114,7 +114,7 @@ "panelIndex": "8", "panelRefName": "panel_6", "title": "Backend Connection Errors", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -127,7 +127,7 @@ }, "panelIndex": "9", "panelRefName": "panel_7", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -141,7 +141,7 @@ "panelIndex": "10", "panelRefName": "panel_8", "title": "HTTP Backend 2XX", - "version": "7.4.0" + "version": "7.3.0" } ], "timeRestore": false, @@ -1006,5 +1006,5 @@ "version": "WzI0MTIsN10=" } ], - "version": "7.4.0" + "version": "7.3.0" } diff --git a/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-lambda-overview.json b/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-lambda-overview.json index 1fd20d1dea6..ecee23ca080 100644 --- a/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-lambda-overview.json +++ b/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-lambda-overview.json @@ -32,7 +32,7 @@ "panelIndex": "8f2d1b8f-fef3-4a9a-9cc8-7f0e2c65e35a", "panelRefName": "panel_0", "title": "AWS Account Filter", - "version": "7.5.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -48,7 +48,7 @@ "panelIndex": "443a9699-3451-44f7-8415-99a16c3f45b3", "panelRefName": "panel_1", "title": "Top Errors", - "version": "7.5.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -64,7 +64,7 @@ "panelIndex": "60a16bf0-2979-467a-b30e-05ea29547b41", "panelRefName": "panel_2", "title": "AWS Region Filter", - "version": "7.5.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -80,7 +80,7 @@ "panelIndex": "349ef0d1-fea1-4b91-b95d-7a668914e10b", "panelRefName": "panel_3", "title": "Lambda Function Duration in Milliseconds", - "version": "7.5.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -96,7 +96,7 @@ "panelIndex": "048b1577-5aed-48e5-8f90-147aa3d56c1a", "panelRefName": "panel_4", "title": "Top Invoked Lambda Functions", - "version": "7.5.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -112,7 +112,7 @@ "panelIndex": "4c8e471c-45da-47be-a866-c5bfc6d28a05", "panelRefName": "panel_5", "title": "Top Throttled Lambda Functions", - "version": "7.5.0" + "version": "7.3.0" } ], "timeRestore": false, @@ -204,7 +204,7 @@ }, "id": "deab0260-2981-11e9-86eb-a3a07a77f530", "migrationVersion": { - "visualization": "7.4.2" + "visualization": "7.3.0" }, "references": [ { @@ -310,7 +310,7 @@ }, "id": "4bf0a740-28d1-11ea-ba6c-49a884eb104f", "migrationVersion": { - "visualization": "7.4.2" + "visualization": "7.3.0" }, "references": [], "type": "visualization", @@ -362,7 +362,7 @@ }, "id": "b5308940-7347-11e9-816b-07687310a99a", "migrationVersion": { - "visualization": "7.4.2" + "visualization": "7.3.0" }, "references": [ { @@ -450,7 +450,7 @@ }, "id": "39dfc8d0-28cf-11ea-ba6c-49a884eb104f", "migrationVersion": { - "visualization": "7.4.2" + "visualization": "7.3.0" }, "references": [], "type": "visualization", @@ -542,7 +542,7 @@ }, "id": "1f3f00c0-28d1-11ea-ba6c-49a884eb104f", "migrationVersion": { - "visualization": "7.4.2" + "visualization": "7.3.0" }, "references": [], "type": "visualization", @@ -642,7 +642,7 @@ }, "id": "915bcd50-28d1-11ea-ba6c-49a884eb104f", "migrationVersion": { - "visualization": "7.4.2" + "visualization": "7.3.0" }, "references": [], "type": "visualization", @@ -650,5 +650,5 @@ "version": "WzI2OTIsM10=" } ], - "version": "7.5.0" + "version": "7.3.0" } diff --git a/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-rds-overview.json b/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-rds-overview.json index 5d8633eb2e1..367104574b6 100644 --- a/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-rds-overview.json +++ b/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-rds-overview.json @@ -32,7 +32,7 @@ "panelIndex": "1", "panelRefName": "panel_0", "title": "Database Connections", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -48,7 +48,7 @@ "panelIndex": "3", "panelRefName": "panel_1", "title": "Insert Latency in Milliseconds", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -64,7 +64,7 @@ "panelIndex": "4", "panelRefName": "panel_2", "title": "Select Latency in Milliseconds", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -80,7 +80,7 @@ "panelIndex": "5", "panelRefName": "panel_3", "title": "Transaction Blocked", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -93,7 +93,7 @@ }, "panelIndex": "6", "panelRefName": "panel_4", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -109,7 +109,7 @@ "panelIndex": "7", "panelRefName": "panel_5", "title": "Insert Throughput in Count/Second", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -125,7 +125,7 @@ "panelIndex": "8", "panelRefName": "panel_6", "title": "Select Throughput in Count/Second", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -141,7 +141,7 @@ "panelIndex": "132653bc-2669-4e8c-b536-06c680e9acf0", "panelRefName": "panel_7", "title": "Disk Queue Depth", - "version": "7.4.0" + "version": "7.3.0" } ], "timeRestore": false, @@ -843,5 +843,5 @@ "version": "WzExNTk1LDhd" } ], - "version": "7.4.0" + "version": "7.3.0" } diff --git a/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-s3-overview.json b/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-s3-overview.json index d69c483c42a..5701193ce16 100644 --- a/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-s3-overview.json +++ b/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-s3-overview.json @@ -29,7 +29,7 @@ }, "panelIndex": "1", "panelRefName": "panel_0", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -42,7 +42,7 @@ }, "panelIndex": "2", "panelRefName": "panel_1", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -55,7 +55,7 @@ }, "panelIndex": "3", "panelRefName": "panel_2", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -68,7 +68,7 @@ }, "panelIndex": "4", "panelRefName": "panel_3", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -81,7 +81,7 @@ }, "panelIndex": "5", "panelRefName": "panel_4", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -94,7 +94,7 @@ }, "panelIndex": "6", "panelRefName": "panel_5", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -107,7 +107,7 @@ }, "panelIndex": "7", "panelRefName": "panel_6", - "version": "7.4.0" + "version": "7.3.0" } ], "timeRestore": false, @@ -713,5 +713,5 @@ "version": "Wzc0NDAsN10=" } ], - "version": "7.4.0" + "version": "7.3.0" } diff --git a/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-sns-overview.json b/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-sns-overview.json index ea5cf1fe0be..e3d9af42885 100644 --- a/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-sns-overview.json +++ b/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-sns-overview.json @@ -55,7 +55,7 @@ }, "panelIndex": "3b9b0cee-b175-4268-8c5b-4ce869a09caf", "panelRefName": "panel_0", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -71,7 +71,7 @@ "panelIndex": "5f0d72c5-0f28-449f-9c93-3b4074f068f7", "panelRefName": "panel_1", "title": "SNS Messages and Notifications", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": {}, @@ -84,7 +84,7 @@ }, "panelIndex": "5a9d5f2f-b075-4892-8188-c6e808a1163d", "panelRefName": "panel_2", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -100,7 +100,7 @@ "panelIndex": "c6d5a54d-61a4-470b-8769-c5b6d6ab6c0f", "panelRefName": "panel_3", "title": "SNS Publish Size", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -116,7 +116,7 @@ "panelIndex": "0684c25d-34e8-425e-9069-dd8364e6325b", "panelRefName": "panel_4", "title": "SNS Notifications Filtered Out", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -132,7 +132,7 @@ "panelIndex": "72e987da-9a49-4dd4-99c4-4acbc49a0e0b", "panelRefName": "panel_5", "title": "SNS Notifications Filtered Out Invalid Attributes", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -148,7 +148,7 @@ "panelIndex": "923bd4cd-d8fe-47b5-afcf-577bf2c5987c", "panelRefName": "panel_6", "title": "SNS Notifications Filtered Out No Message Attributes", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -164,7 +164,7 @@ "panelIndex": "f176153f-4588-42f9-a7bb-3015909d5610", "panelRefName": "panel_7", "title": "SNS Notifications Failed to Redrive to DLQ", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -180,7 +180,7 @@ "panelIndex": "f3c5915b-6848-4950-afca-53653d13d6af", "panelRefName": "panel_8", "title": "SNS SMS Success Rate", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -196,7 +196,7 @@ "panelIndex": "3b3cc747-b57c-44e0-a18c-77155072bee4", "panelRefName": "panel_9", "title": "SNS Notifications Redriven To DLQ", - "version": "7.4.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -212,7 +212,7 @@ "panelIndex": "ee130150-c1de-465b-8a8e-013f466528bf", "panelRefName": "panel_10", "title": "SNS SMS Month To Date Spent USD", - "version": "7.4.0" + "version": "7.3.0" } ], "timeRestore": false, @@ -1122,5 +1122,5 @@ "version": "WzU1MywxXQ==" } ], - "version": "7.4.0" + "version": "7.3.0" } diff --git a/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-usage-overview.json b/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-usage-overview.json index da51dceb5cf..2f96fae244b 100644 --- a/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-usage-overview.json +++ b/x-pack/metricbeat/module/aws/_meta/kibana/7/dashboard/Metricbeat-aws-usage-overview.json @@ -32,7 +32,7 @@ "panelIndex": "2ea7bd59-d748-4e4a-889d-f7e2ca1cfe36", "panelRefName": "panel_0", "title": "Region Filter", - "version": "7.5.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -48,7 +48,7 @@ "panelIndex": "00c2b1f6-3367-4b6f-ac01-7e48b76c262a", "panelRefName": "panel_1", "title": "Usage Resource Count", - "version": "7.5.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -64,7 +64,7 @@ "panelIndex": "fecfe5d4-ef1c-4f38-954a-a2506d72bc5b", "panelRefName": "panel_2", "title": "Usage API Call Count", - "version": "7.5.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -80,7 +80,7 @@ "panelIndex": "69ce7461-36ad-4e7c-b541-c6a1601bf089", "panelRefName": "panel_3", "title": "AWS Account Filter", - "version": "7.5.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -96,7 +96,7 @@ "panelIndex": "62e86407-6ae3-47d3-9136-dd61bdf3267a", "panelRefName": "panel_4", "title": "AWS Service Filter", - "version": "7.5.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -112,7 +112,7 @@ "panelIndex": "196a044c-5c20-4417-8aa0-f60fc502e46c", "panelRefName": "panel_5", "title": "Usage Resource Count Per Service", - "version": "7.5.0" + "version": "7.3.0" }, { "embeddableConfig": { @@ -128,7 +128,7 @@ "panelIndex": "022941b7-01a1-4570-86e9-d03451d4e102", "panelRefName": "panel_6", "title": "Usage API Call Count Per Service", - "version": "7.5.0" + "version": "7.3.0" } ], "timeRestore": false, @@ -819,5 +819,5 @@ "version": "WzU4OSw0XQ==" } ], - "version": "7.5.0" + "version": "7.3.0" } diff --git a/x-pack/metricbeat/module/aws/fields.go b/x-pack/metricbeat/module/aws/fields.go index 9ac2b8fba44..f87d9369418 100644 --- a/x-pack/metricbeat/module/aws/fields.go +++ b/x-pack/metricbeat/module/aws/fields.go @@ -19,5 +19,5 @@ func init() { // AssetAws returns asset data. // This is the base64 encoded gzipped contents of module/aws. func AssetAws() string { - return "eJzsXV9z27ayf8+n2OlT0nF07ml77kMe7oxjee7xjNM6ljt9ZCFgReEYBGj8saxMP/wd/CFFSZQlSqScztw8tBlRAn6/3cVisbtgPsIjLj8BWZh3AJZbgZ/gB7IwP7wDYGio5qXlSn6C/3kHAPAnWZg/oVDMCQSqhEBqDVz+MYFCSW6V5jKHAq3m1MBMqyI8uxLKsQWxdD56B6BRIDH4CXLyDmDGUTDzKYz+ESQp8BNQ//0RoVQ5aUf+s/AYwC5L/OQRL5Rm6bMWlP7PwxzjOJDGCWOD0kAEJwacQQZWAWcoLZ8tgfHZDDVKC/4Dy9EAl0CgcMLyjxYlCY+euVayQGlHa5CjAFcYc61c+RrCJu/mQJbkZvRj/XE1npr+B6ltfBw/yNoksvE4K0hZcpmn7/7w4w+N7+2QXpAgyf3A8EyEQygJ10mlZGFAo1FOUzSjLQbm59HU0Udc09wu7e3B8GvQ2QwITH6GNOrWhIwXKA1X8jsR3Jdg/01Ym6Yy+nGUFsnoxxpzC941rEy5qcDtJzth7oD4JS1POycWNFqnJbKo2dVChcu7G3hyqJfb8p5yIbjMt0TdtPk9IvozjfEnUCUt4dLDQUBjeUEsMqBzonM0MFMalsrp4Eeqlczlhkup/tSuZYqWND7ftdhoPcpJZFbDbPApmqJeoEYwVJOyEnftG/8IIl/MOZ2vBmjxqMa7p2nTV3kepiRrC3HTxe6SQlMS9ThrT3ev2T0igeSB62HBlEj5jCODxRxlNK2G/IGUvGVlLyUpFJuepJ1qkDPpxv9wHKYcfz7FNnFqTqKNU3NGxtefJ90NsKZKfzqNKv3pnFSvfjptrdHSjayyRIzKtZ1pRd5QIpBlM6HI5hcOWHQlaorSkjxunUIoGnzq9dVPQFVROovgJLdJPEQjUKe9OxFL71udQVAyyJFLY4mkONpJhGpk3GbOkLzddwi1tlUcyEG6Yora47+6+x3iJMY7kaiHJrawR/hvOcsF/0b8sHvxTonwvx0EMZKwozaBR0HLFeY5MX470w4ZGO4/4RYWxIAgTtI5Mh+pGku0RbabjHG6FM5kZyCVplpnNCfPCFNEudIMkeCk4AX3FlfTDT7f/+zq7verMMLniDVFl9zAN9TqUKYmi/HB5o7UE9XApZWwXytSWR8NM2BqIT3lbX1fAJEsuRU7d/4kQZ32siGMcY+CiBTitFOWaBdKP464HJXER71mEKZpbNBIkT97o5PeX1TTA5cW9cxHF5uL7lDYWYk6M0gHhV+iBoNUSRYdtXK2LybK2bNoYEDcf3cVcDmaLi0eLP+Z0gWxn6DtR524hQGGWBth4EHVEqE3lNI3C29fb6mVIdbLG6ilLxqMm0euRhoJO5taPqflQVJQ7fHXG76xSiM8K+EKNECeCRdkKhCsOoZNz0ppIG/oYhgSC80tnlknfk6L0uMcks8gWqmwNxQzBI1gW6rsa1O/UkUp0Ie8wapUiTqcQ8zxVhWzz6u0SYmaK+a9iOXFYeR6VtBukn2sohP4RpscQpth5CbTI22xD3KDaXOL5Olr7xi+xhLrzIjOkT5mM8JFb8e7eyyVtsafQu0c9TpSfxIviTHIYKrsfP1hxAQBUzjT+admaSwW6894zJcIYiwUXDp7OMksjndmrkMQqeZ5AyrtGjuUTL1lUKX9f5xsz8v5sCxHfXI6S+lU2ti/X9VPeUFyHPH2NXF0gv5mHBalh+HHr8uiMQ3VBd8qazryOuixkHAjGackBAfJEhjaYHHNVC03gNL7oh35shpoqfkzsThi0mQbFcoeBJpGh/Gvk1RxjuLdiuwPRMnLdkvc/LgDtJu751+AMKbRGCDGKMpDfnjBk/vrjNVNBadDCTQMviXPA60yQetRipXgEo5r71w4hZu7+sl7L+APMFUubqDHiDQsoRFVrF2aRzuiMO6mDC+AGCDwz//+OOUWnDQ8lyF7GyY5CGn/em9FCu9LlMwv979AOynj38zcWctl/jFkZP8Ci7rgMtj0Xz5iCeXx6q/IPuxhZOc+vo3xlnfVQ20FaZ4QblXbwnYNFMVp5U8U56x8Xt+2Fz0PqgMKUkwZOYltHOKMhG/DhKcUejU7rdCr2TkLvffjIwq90Ff1s0qNpBLnEbvJWm20a9Xw/6uc565yMmLJlBjMqJISaTifDkKnmggaE6Vi+A5k0/q8MyJa9rf5XRbkm5JwnzrsQg/c+8v7Xz8EE0BC595l7AdFBTHtsjoK1lXTwzQjsaqlwB+PCyyUXgIlJaHcLiFgqL44/rwvN9dAn/oy+dYW2wcF4tWqPxpXloIjWyl/NesIHubcND7wBwzPwkn+5DB0RgZ7r7/hh+1EMR5V+6M3SemWiDO1dDTjKG5qprtTTtmTQ4cZw9LOW7Ed2ZWyWmrKWS+BEMbd/GbgvQ+D/hGzUBqfHBprPsCCcB/ThQwUpT6u9qw8wnbsVTLlSWQG9TPqjOQobfYfNR3GY8QJYfL1FiZhQrj0E4KfEJgLO+hB2YeZRvQH1yyunrPW1UgROirVrJHL00QyVVRST6B2Is+MVZrk56tx7IKdcEDoN2zHW5AXXrgicwZZZjWRhgRPn3HWp42kaaAxA9yMq5YZEztmPIYRXAYPFPLKd8rYXOPk6207eCUYGptpLAWnYf/PjFA2EyQfFdMe4QuS5954Df9WO/k0a/0shJnKhF5cf9wKTv6Py9vgYOpqcyd+3gtkXO1NdR/pf8gzBvNobPncPMZSxs0/fmvPf+9CGoQRJN8hIV/ZPHNxolPM3vICgcC9R3+fdNPYfLyevJ3NeZWzjrFEc39q6ubLcvL19gK+EM3J+HNsX1rpa22aHZGHWZAyxsdv5Ag8gLj2YxIzdTCuMQ5bejzV+O1cKtvwHz66WjnzdpZNnyFUbrIcJbZq85QFGAyzQcUfBRquxE/caWWFrfX8Syvu6B3X1pNDzQ83n6PQpTkAX5A6i2wvKIaECUUfh4VVz1LVLeqwdB++WI8L29pbrb60+Vb2Gu9sOK30ml+68NTCZK8EFEJRIt44rKj4rLsHi0WpNNFLsP4zE/ykX477eAmVcxnKZE4PbNwpLA0zArEest2/7OxcK5fPS2dHVBUFb8/M9OYf4hxd/EIDIEOBO+pL/TmwMEftKbqgY2JYaOPxbX1M6gSsGBgYlwa1NRfgSkYspi7oKMlOSONA5wB7jIJTKadXeLXfqepEq/liV0Ldvxn7a3xU5yOCglsbC7ZUcJTWxH50Ol/rxPB7SfLFIdDzHpkKZyzqleM6QgRZQtWnKLikqvAnjPf3cfAPK5loMptx2hLZeRZUuJBRCOKizlhVoF5todWPveiqDNt4Un8c9i3v4hvpbxL6ZuvT1sFSqTTTp1iUs7kKYnlIo/995OKPWEMs5o3TkCWPqW8wRJ9rcedejAYF7ihH9OZy4hzHuJzoUIdFF+c4Bl2I84cFN93saw0q3odREIuSLrtGNH2e0xOEsIS2gp7gfAsuBI8sdgWPiUaXyGIoDiG9w3DGJY9nUSJz53X1fjy+/VDHJV2ZdQhNhmL2avTSkU/HAGZYStWS7sihk9fugUFfTr3C39GjD6WDdaffUQcd/f5QHNa3ho4cuu0O35EhhWJYymjykO57o1xEIx2oKHUljymWKZdEL0P6oQr9CuJj+u3Mbsxy61cTuA26myWGfssLLdnNxoTgJ4QZF9gtx9mAv5mkHRz+ScnZxo/NyP9/x3mqr/xQVRduzpsyoT64VxKIrE6Lq7p4dZrcGxY22UyFoo+9XtLeprNGYzNvWt/ZTkj2J3ob5Xk2zdIhORuiGeHI9oIEqbpbQYkQ0Umnw9sq55q+uZ+oVqLH3s3xZ/ADGhD8EeGP+5uH63tQGu6vL8fX9xd9AkeZc4k99xxfEzpfK6VpJ5Ps43wXkdlmyaxRLvOBI1ra9mqsjBEullVy+90m4i59f5uDbTQBhmd1HnvIlsDJz6d1BKb3ehn+7a2y/eFUUyfCwh0nFq8wbb5zrIk7OqFMzbL4Nq4+8/qhQ7LZMxNnaMEW1hARolZ16LlqfzFbls5np9pdGqZhcemT79rOqsNpbD8dUFn/fni4W6XoC8LC/Ti/rUZXV7/L7gI05kQzUV0oWJY7Oldq7Dm2n2lO7WYKmP/3+mEDtzeuyva4bOOwB2/pBsR793vveF8pLvUCeXx9e/1w3Tfq+a7Dei+Y/319OT7InvfZgjJDGsNvk01rOArlK4mDU3GukEyub6+vHuC3oPTQmOodXc9WEZlkhhIpz9wZsJm6rTbZhCXeNTtYHKewr95w+V3Qr1+3eQb+gg+52mpsYaf3c6Vm8ADdxJe2voaTqYUUirC30UxUywpDWGyHbdmLuQ9rYlOkKZUMx2MqHAtHtKliO5plXfnWdCsEUWcp7AJSB28e+0V3z4laK21Gv7y8DGduv7y8pBJ3nK6+560YHqS3uOJIet+cmgHycJX4v/zZ9J+vEvvXkMT+9fICsV/9jMSq3OyMa2MzbxyjorNFHp+iLVF/rGwuJGfD2aC6SxIab2qTRH8aqLsf4gsGt0RgVXzD4NqiDPeKQgpuirXjfV0eIZCvTjdnFQkKUpqYoNohmqCrsJBX4kiXi8MNg/AkHJf2rd36PChPu3ho5DkvHk5+bb94eOAtS/N0Itmns5L9euIty3RZoEBjSI4ZyfHMneplqdVLeJk3pMuWXmYRFkglP8aDFoMEscrdhttHO25vxG+GMxpZ9pdXXvfK1SxrgFaZ5DR3yPFt949rJKHZhhcFMk4sih3BQM1FKps9c8OnO3Kwp24yNZ2aAZcwEzyf79jNa2RnQbUpPqs5PhOxcnsH2oM3pWGRVvbaCVnlqYeFVp8qpkugRAhTbQyphe5LWmKxTLIHstm+V923zhmLexd5TYZYlHZZdRgOc4NvQzyXdzeV+PxaYTyu8ChdIBWBHfdfUK7c7dlT2dVVrY4yjo/6rZ9Mvk6Sz1wbtz4FmVPrHmGEHXvx5r9i4deBJvQxThua8FSBYYtt+RdM9kcV/xcAAP//TCejCQ==" + return "eJzsXV9z27ayf8+n2OnLSTKOzj1tz33Iw51xLM89nnFbx3KnjywErCgcgwCNP5aV6Ye/gz+kKImyRImUc2ZuHtqMKAG/3+5isdhdMJ/gEZefgSzMOwDLrcDP8ANZmB/eATA0VPPSciU/w/+8AwD4kyzMn1Ao5gQCVUIgtQYu/5hAoSS3SnOZQ4FWc2pgplURnl0J5diCWDofvQPQKJAY/Aw5eQcw4yiY+RxG/wSSFPgZqP/+iFCqnLQj/1l4DGCXJX72iBdKs/RZC0r/52GOcRxI44SxQWkgghMDziADq4AzlJbPlsD4bIYapQX/geVogEsgUDhh+SeLkoRHz1wrWaC0ozXIUYArjLlWrnwNYZN3cyBLcjP6WH9cjaem/0ZqGx/HD7I2iWw8zgpSllzm6bs/fPyh8b0d0gsSJLkfGJ6JcAgl4TqplCwMaDTKaYpmtMXA/DSaOvqIa5rbpb09GH4NOpsBgclPkEbdmpDxAqXhSn4ngvsl2H8T1hbkv30cpVUy+jj6+LeOqJlyU4FDgDZg58SCRuu0RBb1vVq+cHl3A08O9XKb0pQLwWW+RaW5EvZg+DON8SdQJS3h0sNBQGN5QSwyoHOiczQwUxqWyungXar1zeWGo6n+1A5nipY0Pt+1BGk9yklkVsNs8Cmaol6gRjBUk7ISd+0x/wgiX8w5na8GaPGzxjutadODeR6mJGvLc9Px7pJCUxL1OGtPd6/kPSKB5JfrYcGUSPmMI4PFHGU0rYb8gZS8Zb0vJSkUm56knWqQM+nG/3Acphx/OcU2cWpOoo1Tc0bG118m3Q2wpkp/PI0q/fGcVK9+PG2t0dKNrLJEjMo1z78ibygRyLKZUGTzCwcsuhI1RWlJHjdUIRQNPvX66kegqiidRXCS2yQeohGo096diKX3rc4gKBnkyKWxRFIc7SRCNTJuM2dI3u47hFrbKg7kIF0xRe3xX939DnES451I1EMTW9gj/Lec5YJ/I37YvXinRPjfDoIYSdhRm8CjoOUK85wYv51phwwM959wCwtiQBAn6RyZj1+NJdoi203GOF0KZ7IzkEpTrTOak2eEKaJcaYZIcFLwgnuLq+kGn+9/dnX3+1UY4UvEmmJObuAbanUoU5PF+GBzR+qJauDSStivFamsj5EZMLWQnvK2vi+ASJbcip07f76gTnvZEMa4R0FECnHaKUu0C6UfR1yOSuJjYTMI0zQ2aKTIn73RSe8vqumBS4t65qOLzUV3KOysRJ0ZpIPCL1GDQaoki45aOdsXE+XsWTQwIO7/dBVwOZouLR4s/5nSBbGfoe1HnbiFAYZYG2HgQdUSoTeU0jcLb19vqZUh1ssbqKUvGoybR65GGgk7m1q+pOVBUlDt8dcbvrFKIzwr4Qo0QJ4JF2QqEKw6hk3PSmkgb+hiGBILzS2eWSd+TovS4xySzyBaqbA3FDMEjWBbquxrU79SRSnQh7zBqlSJOpxDzPFWFXPSq7RJiZor5r2I5cVh5HpW0G6SfayiE/hGmxxCm2HkJtMjbbEPcoNpc4vk6WvvGL7GEuvMiM6RPmYzwkVvx7t7LJW2xp9C7Rz1OlJ/Ei+JMchgqux8/WHEBAFTONP5p2ZpLBbrz3jMlwhiLBRcOns4ySyOd2auQxCp5nkDKu0aO5RMvWVQpf1/nGzPy/mwLEd9cjpL6VTa2L9f1U95QXIc8fY1cXSC/mYcFqWH4cevi6UxDdUF3yprOvI66LGQcCMZpyQEB8kSGNpgcc1ULTeA0vuiHfmyGmip+TOxOGLSZBt1yx4EmkaH8a+TVIeO4t2K7A9Eyct2S9z8uAO0m7vnn4EwptEYIMYoykN+eMGT++uM1U0Fp0MJNAy+Jc8DrTJB61GKleASjmvvXDiFm7v6yXsv4A8wVS5uoMeINCyhEVWsXZpHO6Iw7qYML4AYIPCP//405RacNDyXIXsbJjkIaf96b0UK70uUzC/3v0A7KePfzNxZy2X+KWRk/wKLuuAy2PRfPmIJZfLqr8g+7GFk5z6+jfGWd9VDbQVpnhBuVdvCdg0UxWnlTxTnrHxe37YXPQ+qAwpSTBk5iW0c4oyEb8OEpxR6NTut0KvZOQu99+MjCr3QV/WzSo2kEucRu8labbRr1fD/q5znrnIyYsmUGMyokhJpOJ8OQqeaCBoTpWL4DmTT+rwzIlr2t/ldFuSbknCf+u5CZ9z7y/tfPwQTQELn3mXsB0UFMe2yOgrWVdPDNCOxqqXAH48LLJReAiUlodwuIWCovjj+si8310CfujX51hbbBwXi1ao/GVeWgiNbKX816wge5tw0PvAHDM/CSf7kMPRLBnuvv+GH7UQxHlX7ozdJ6ZaIM7V0NOMobmqmu1NO2ZNDhxnD0s5bsR3ZlbJaaspZL4EQxt38ZuC9D4P+HrNQGp8cGms+wIJwH9OFDBSlPq72rDzCduxVMuVJZAb1M+qM5Cht9m81HcZjxAlh8vUWJmFCuPQTgp8QmAs76EHZh5lG9AfXLK6es9bVSBE6KtWskcvTRDJVVFJPoHYiz4xVmuTnq3Hsgp1wQOg3bMdbkBdeuCJzBllmNZGGBE+fcdanjaRpoDED3IyrlhkTO2Y8hhFcBg8U8sp3ythc4+TrbTt4JRgam2ksBadh/8+MUDYTJB8V0x7hC5Ln3ngN/1Y7+TRr/SyEmcqEXlx/3ApO/o/L2+Bg6mpzJ37eC2Rc7U11H+l/yDMG82hs+dw8xlLGzd9/a89/70IahBEk3yEhX9k8c3GiU8ze8gKBwL1Hf59009h8vJ68nc15lbOOsURzf2rq5pfl5OvtBfxCNCfjL7F9aaWvtWl2RB5mQcoYH7+RI/AA4tqPSczUwbjGOGzp8VTjt3OpbMN/+Ohq5czbWTZ9hlC5yXKU2KrNUxZgMMwGFX8UaLgSP3GnlRW21vMvrbijd1xbTw41P9x8jkKX5gB8Qeossr2gGBImFH0cFlY9S1W3qMPSffhiPS5sa2+1+tLmW9lrvLPhtNJrfunCUwuTvRJQCEWJeOOwouKz7h4sFqXSRC/B+s9M8JN+Oe7jJVTOZSiTOT2wcaewNMwIxHrIdv+ys3OtXD4vnR1RVRS8PTPTm3+Ic3TxCw2ADAXuqC/158DCHLWn6IKOiWGhjce39TGpE7BiYGBcGtTWXIArGbGYuqCjJDshjQOdA+wxCk6lnF7h1X6nqhOt5otdCXX/Zuyv8VGdjwgKbm0s2FLBUVoT+9HpfK0Tw+8lyReHQM97ZCqcsahXjusIEWQJVZ+i4JKqwp8w3t/HwT+sZKLJbMZpS2TnWVDhQkYhiIs6Y1WBerWFVj/2oqsybONJ/XHYt7yLb6S/SeibrU9bB0ul0kyfYlHO5iqI5SGN/p8jF3/EGmIxb5yGLHlMfYMh+lyLO/diNChwRzmiN5cT5zjG5USHOiy6OMcx6EKcPyy46WZfa1DxPoyCWJR02TWi6fOcniCEJbQV9ATnW3AheGSxK3hMNLpEFkNxCOkdhjMueTyLEpk7r6v34/Hthzou6cqsQ2gyFLNXo5eOfDoGMMNSqpZ0Rw6dvHYPDPpy6hX+jh59KB2sO/2OOujo94fisL41dOTQbXf4jgwpFMNSRpOHdN8b5SIa6UBFqSt5TLFMuSR6GdIPVehXEB/Tb2d2Y5Zbv5rAbdDdLDH0W15oyW42JgQ/Icy4wG45zgb8zSTt4PBPSs42fmxG/v87zlN95YequnBz3pQJ9cG9kkBkdVpc1cWr0+TesLDJZioUfez1kvY2nTUam3nT+s52QrI/0dsoz7Nplg7J2RDNCEe2FyRI1d0KSoSITjod3lY51/TN/US1Ej32bo6/gB/QgOCPCH/c3zxc34PScH99Ob6+v+gTOMqcS+y55/ia0PlaKU07mWQf57uIzDZLZo1ymQ8c0dK2F2ZljHCxrJLb7zYRd+n72xxsowkwPKvz2EO2BE5+Oq0jML3ty/Bvb5XtD6eaOhEW7jixeIVp801kTdzRCWVqlsW3cvWZ1w8dks2emThDC7awhogQtapDz1X769qydD471e7SMA2LS59813ZWHU5j++mAyvrXw8PdKkVfEBbux/ltNbq6+g13F6AxJ5qJ6kLBstzRuVJjz7H9THNqN1PA/L/XDxu4vXFVtsdlG4c9eEs3IN6733vH+0pxqRfI4+vb64frvlHPdx3We8H8r+vL8UH2vM8WlBnSGH6bbFrDUShfSRycinOFZHJ9e331AL8FpYfGVO/oeraKyCQzlEh55s6AzdRttckmLPGu2cHiOIV99YbL74J+/brNM/AXfMjVVmMLO72fKzWDB+gmvsr1NZxMLaRQhL2NZqJaVhjCYjtsy17MfVgTmyJNqWQ4HlPhWDiiTRXb0SzryremWyGIOkthF5A6ePPYL7p7TtRaaTP6+eVlOHP7+eUllbjjdPU9b8XwIL3FFUfS++bUDJCHq8T/5c+m/3iV2D+HJPbPlxeI/epnJFblZmdcG5t54xgVnS3y+BRtifpTZXMhORvOBtVdktB4U5sk+tNA3f0QXzC4JQKr4hsG1xZluFcUUnBTrB3v6/IIgXx1ujmrSFCQ0sQE1Q7RBF2FhbwSR7pcHG4YhCfhuLRv7dbnQXnaxUMjz3nxcPJr+8XDA29ZmqcTyT6dlezXE29ZpssCBRpDcsxIjmfuVC9LrV7Cy7whXbb0MouwQCr5KR60GCSIVe423D7acXsjfjOc0ciyv7zyuleuZlkDtMokp7lDjm+7f1wjCc02vCiQcWJR7AgGai5S2eyZGz7dkYM9dZOp6dQMuISZ4Pl8x25eIzsLqk3xWc3xmYiV2zvQHrwpDYu0stdOyCpPPSy0+lQxXQIlQphqY0gtdL+kJRbLJHsgm+171X3rnLG4d5HXZIhFaZdVh+EwN/g2xHN5d1OJz68VxuMKj9IFUhHYcf8F5crdnj2VXV3V6ijj+Kjf+snk6yT5zLVx61OQObXuEUbYsRdv/isWfh1oQh/jtKEJTxUYttiWf9dkf1TxfwEAAP//ZwWk3g==" } diff --git a/x-pack/metricbeat/module/istio/_meta/Dockerfile b/x-pack/metricbeat/module/istio/_meta/Dockerfile new file mode 100644 index 00000000000..e69de29bb2d diff --git a/x-pack/metricbeat/module/istio/_meta/config.reference.yml b/x-pack/metricbeat/module/istio/_meta/config.reference.yml new file mode 100644 index 00000000000..8fe23bdf2ad --- /dev/null +++ b/x-pack/metricbeat/module/istio/_meta/config.reference.yml @@ -0,0 +1,4 @@ +- module: istio + metricsets: ["mesh"] + period: 10s + hosts: ["localhost:42422"] diff --git a/x-pack/metricbeat/module/istio/_meta/config.yml b/x-pack/metricbeat/module/istio/_meta/config.yml new file mode 100644 index 00000000000..8fe23bdf2ad --- /dev/null +++ b/x-pack/metricbeat/module/istio/_meta/config.yml @@ -0,0 +1,4 @@ +- module: istio + metricsets: ["mesh"] + period: 10s + hosts: ["localhost:42422"] diff --git a/x-pack/metricbeat/module/istio/_meta/docs.asciidoc b/x-pack/metricbeat/module/istio/_meta/docs.asciidoc new file mode 100644 index 00000000000..24b262314e5 --- /dev/null +++ b/x-pack/metricbeat/module/istio/_meta/docs.asciidoc @@ -0,0 +1,9 @@ +This is the Istio module. The Istio module collects metrics from the +Istio https://istio.io/docs/tasks/observability/metrics/querying-metrics/#about-the-prometheus-add-on[prometheus exporters endpoints]. + +The default metricset is `mesh`. + +[float] +=== Compatibility + +The Istio module is tested with Istio 1.4 diff --git a/x-pack/metricbeat/module/istio/_meta/fields.yml b/x-pack/metricbeat/module/istio/_meta/fields.yml new file mode 100644 index 00000000000..62608c294b1 --- /dev/null +++ b/x-pack/metricbeat/module/istio/_meta/fields.yml @@ -0,0 +1,11 @@ +- key: istio + title: "istio" + description: > + istio Module + release: beta + fields: + - name: istio + type: group + description: > + `istio` contains statistics that were read from Istio + fields: diff --git a/x-pack/metricbeat/module/istio/doc.go b/x-pack/metricbeat/module/istio/doc.go new file mode 100644 index 00000000000..facfbe7beb1 --- /dev/null +++ b/x-pack/metricbeat/module/istio/doc.go @@ -0,0 +1,6 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +// Package istio is a Metricbeat module that contains MetricSets. +package istio diff --git a/x-pack/metricbeat/module/istio/docker-compose.yml b/x-pack/metricbeat/module/istio/docker-compose.yml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/x-pack/metricbeat/module/istio/fields.go b/x-pack/metricbeat/module/istio/fields.go new file mode 100644 index 00000000000..a6cfe7f8317 --- /dev/null +++ b/x-pack/metricbeat/module/istio/fields.go @@ -0,0 +1,23 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +// Code generated by beats/dev-tools/cmd/asset/asset.go - DO NOT EDIT. + +package istio + +import ( + "github.com/elastic/beats/libbeat/asset" +) + +func init() { + if err := asset.SetFields("metricbeat", "istio", asset.ModuleFieldsPri, AssetIstio); err != nil { + panic(err) + } +} + +// AssetIstio returns asset data. +// This is the base64 encoded gzipped contents of module/istio. +func AssetIstio() string { + return "eJzUmM9y27gPx+9+CkyPv2n1AD78Znb2sjnsTKebe0uRcMSaIrgEGNd9+h3qj6PIjOI49rqrQyamRHw/AEgQ0ifY4n4NlsXSCkCsOFzDh+73hxWAQdbRBrHk1/D/FQD0z8KfZJLDFUBEh4pxDTWKWgFsLDrD6+7RT+BVi0/m8yX7gGt4iJTCMFLQyNe3btY30ORFWc/AoiSPaQZplMAOI0JEZWATqYW7icgUYgrSIjeHwRLLAk++fi+wRHRK0IAQSIM9RicEjPHRapxYmAdrvOa8z4LnWZR/ZuaJXfCHzG4s4OfrvkEIkVqUBhOXrY/S36kuqm5xv6No3iU8tz1qRvw7IQsXhR35hzeqkih3MAqN8sahgXoPyg+5CpF+7JdYKpOiygJVy1Wd9Bal+l+Rj+rvqOcJ6Qe/nuvBlx4CRghoLAs9RNVCz5KTCK11zjJq8oZP9oVTe2qYNxRbJesDxVk+8GH6R+DUAm0OA+c7oSn5ecjfGespp09tjTGjFlfmnIztT6zqveANV8pf9icer5JTsd+wKM7jmQsssFwht3Oa5xIvgHEgz/jfS+4x9w2zewzzq6Q3UBSMlzvqvgwWwRr0YjcWuesNRqVcTfrf/YqHOwHLwCi5izDIYn1f6+1mmJTvd22O6toKjNPDC5Q3wJSixuIM7Sx6mc6oipHoTVQ7iltHylR59JINgOV5RLJCjsYAPyrDrrG66Vq/SK5/dIA7GZyDeqFpuih9JzMmdObGImyI1msblLsuY0CMcNAaQSWqzcbqkWWyAHcN+n6SStJkU3pYigyJcdknFcJ1vRkCrEKAWjEaIN/9cKpGd04WHjHycTtzYepB5FW+IuikHNxiZ06r0XJEXwS9xU48D/uX2JNToHdvzKmxq+/OadCXt2gxPa97cIvdurySXkUePgJUDXG51bkI9xRyUISsOLZdtnaY3+HyW6/1mlrrHw7tx8k+XL/qlPzIqm9j/LcLToH6lRUyhj5EEtJ07XozqCz3nb99vnt60m7y/4/WoPkIJA3GneXDTKCYmzOPuvN5nFXO0qHz12TKWTnjs07By1EHss6Rq92MvgZZhhCRc0tM3u1zgfrj/v4ztCjRai578eRuxahTtLKvAjmr91fueIZdMCv6vfRyQtskSbmv4rg/PPr+fzguugfUNkerbZMf7Xa+YfdCMXuNeOFYEoLkt552vheZzRp6HbY+/x0CN9Jr5T0J1N0KDRhdvhNS9z21Wv0TAAD///m4gQY=" +} diff --git a/x-pack/metricbeat/module/istio/mesh/_meta/data.json b/x-pack/metricbeat/module/istio/mesh/_meta/data.json new file mode 100644 index 00000000000..fd43fc1aaca --- /dev/null +++ b/x-pack/metricbeat/module/istio/mesh/_meta/data.json @@ -0,0 +1,112 @@ +{ + "@timestamp": "2019-03-01T08:05:34.853Z", + "event": { + "dataset": "istio.mesh", + "duration": 115000, + "module": "istio" + }, + "istio": { + "mesh": { + "connection": { + "security": { + "policy": "unknown" + } + }, + "destination": { + "app": "reviews", + "principal": "unknown", + "service": { + "host": "details.default.svc.cluster.local", + "name": "details", + "namespace": "default" + }, + "version": "v1", + "workload": { + "name": "reviews-v1", + "namespace": "default" + } + }, + "reporter": "source", + "request": { + "duration": { + "ms": { + "bucket": { + "+Inf": 1, + "10": 1, + "100": 1, + "1000": 1, + "10000": 1, + "25": 1, + "250": 1, + "2500": 1, + "5": 0, + "50": 1, + "500": 1, + "5000": 1 + }, + "count": 1, + "sum": 5.815905 + } + }, + "protocol": "http", + "size": { + "bytes": { + "bucket": { + "+Inf": 1, + "1": 1, + "10": 1, + "100": 1, + "1000": 1, + "10000": 1, + "100000": 1, + "1000000": 1, + "10000000": 1, + "100000000": 1 + }, + "count": 1, + "sum": 0 + } + } + }, + "requests": 1, + "response": { + "code": "200", + "size": { + "bytes": { + "bucket": { + "+Inf": 1, + "1": 0, + "10": 0, + "100": 0, + "1000": 1, + "10000": 1, + "100000": 1, + "1000000": 1, + "10000000": 1, + "100000000": 1 + }, + "count": 1, + "sum": 178 + } + } + }, + "source": { + "app": "productpage", + "principal": "unknown", + "version": "v1", + "workload": { + "name": "productpage-v1", + "namespace": "default" + } + } + } + }, + "metricset": { + "name": "mesh", + "period": 10000 + }, + "service": { + "address": "127.0.0.1:55555", + "type": "istio" + } +} \ No newline at end of file diff --git a/x-pack/metricbeat/module/istio/mesh/_meta/docs.asciidoc b/x-pack/metricbeat/module/istio/mesh/_meta/docs.asciidoc new file mode 100644 index 00000000000..19457b9f51e --- /dev/null +++ b/x-pack/metricbeat/module/istio/mesh/_meta/docs.asciidoc @@ -0,0 +1 @@ +This is the mesh metricset of the module istio. This metricset collects all Mixer-generated metrics. diff --git a/x-pack/metricbeat/module/istio/mesh/_meta/fields.yml b/x-pack/metricbeat/module/istio/mesh/_meta/fields.yml new file mode 100644 index 00000000000..3e7534b2c98 --- /dev/null +++ b/x-pack/metricbeat/module/istio/mesh/_meta/fields.yml @@ -0,0 +1,131 @@ +- name: mesh + type: group + description: > + Contains statistics related to the Istio mesh service + release: beta + fields: + - name: instance + type: text + description: > + The prometheus instance + - name: job + type: keyword + description: > + The prometheus job + - name: requests + type: long + description: > + Total requests handled by an Istio proxy + - name: request.duration.ms.bucket.* + type: object + object_type: long + description: > + Request duration histogram buckets in milliseconds + - name: request.duration.ms.sum + type: long + format: duration + description: > + Requests duration, sum of durations in milliseconds + - name: request.duration.ms.count + type: long + description: > + Requests duration, number of requests + - name: request.size.bytes.bucket.* + type: object + object_type: long + description: > + Request Size histogram buckets + - name: request.size.bytes.sum + type: long + description: > + Request Size histogram sum + - name: request.size.bytes.count + type: long + description: > + Request Size histogram count + + - name: response.size.bytes.bucket.* + type: object + object_type: long + description: > + Request Size histogram buckets + - name: response.size.bytes.sum + type: long + description: > + Request Size histogram sum + - name: response.size.bytes.count + type: long + description: > + Request Size histogram count + + - name: reporter + type: keyword + description: > + Reporter identifies the reporter of the request. It is set to destination if report is from a server Istio proxy and source if report is from a client Istio proxy. + - name: source.workload.name + type: keyword + description: > + This identifies the name of source workload which controls the source. + - name: source.workload.namespace + type: keyword + description: > + This identifies the namespace of the source workload. + - name: source.principal + type: keyword + description: > + This identifies the peer principal of the traffic source. It is set when peer authentication is used. + - name: source.app + type: keyword + description: > + This identifies the source app based on app label of the source workload. + - name: source.version + type: keyword + description: > + This identifies the version of the source workload. + + - name: destination.workload.name + type: keyword + description: > + This identifies the name of destination workload. + - name: destination.workload.namespace + type: keyword + description: > + This identifies the namespace of the destination workload. + - name: destination.principal + type: keyword + description: > + This identifies the peer principal of the traffic destination. It is set when peer authentication is used. + - name: destination.app + type: keyword + description: > + This identifies the destination app based on app label of the destination workload.. + - name: destination.version + type: keyword + description: > + This identifies the version of the destination workload. + + - name: destination.service.host + type: keyword + description: > + This identifies destination service host responsible for an incoming request. + - name: destination.service.name + type: keyword + description: > + This identifies the destination service name. + - name: destination.service.namespace + type: keyword + description: > + This identifies the namespace of destination service. + + - name: request.protocol + type: keyword + description: > + This identifies the protocol of the request. It is set to API protocol if provided, otherwise request or connection protocol. + - name: response.code + type: long + description: > + This identifies the response code of the request. This label is present only on HTTP metrics. + - name: connection.security.policy + type: keyword + description: > + This identifies the service authentication policy of the request. It is set to mutual_tls when Istio is used to make communication secure and report is from destination. It is set to unknown when report is from source since security policy cannot be properly populated. diff --git a/x-pack/metricbeat/module/istio/mesh/_meta/testdata/config.yml b/x-pack/metricbeat/module/istio/mesh/_meta/testdata/config.yml new file mode 100644 index 00000000000..ab6bf241654 --- /dev/null +++ b/x-pack/metricbeat/module/istio/mesh/_meta/testdata/config.yml @@ -0,0 +1,3 @@ +type: http +url: "/metrics" +suffix: plain diff --git a/x-pack/metricbeat/module/istio/mesh/_meta/testdata/docs.plain b/x-pack/metricbeat/module/istio/mesh/_meta/testdata/docs.plain new file mode 100644 index 00000000000..c7e0ee303a8 --- /dev/null +++ b/x-pack/metricbeat/module/istio/mesh/_meta/testdata/docs.plain @@ -0,0 +1,281 @@ +# HELP istio_request_bytes request_bytes +# TYPE istio_request_bytes histogram +istio_request_bytes_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="10"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="100"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1000"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="10000"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="100000"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+06"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+07"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+08"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="+Inf"} 1 +istio_request_bytes_sum{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 0 +istio_request_bytes_count{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="10"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="100"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1000"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="10000"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="100000"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1e+06"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1e+07"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1e+08"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="+Inf"} 1 +istio_request_bytes_sum{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system"} 0 +istio_request_bytes_count{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="10"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="100"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1000"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="10000"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="100000"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+06"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+07"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+08"} 1 +istio_request_bytes_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="+Inf"} 1 +istio_request_bytes_sum{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 0 +istio_request_bytes_count{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="10"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="100"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1000"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="10000"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="100000"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+06"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+07"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+08"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="+Inf"} 1 +istio_request_bytes_sum{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 0 +istio_request_bytes_count{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="10"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="100"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1000"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="10000"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="100000"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1e+06"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1e+07"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1e+08"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="+Inf"} 1 +istio_request_bytes_sum{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system"} 0 +istio_request_bytes_count{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="10"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="100"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1000"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="10000"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="100000"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+06"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+07"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+08"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="+Inf"} 1 +istio_request_bytes_sum{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 0 +istio_request_bytes_count{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="1"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="10"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="100"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="1000"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="10000"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="100000"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="1e+06"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="1e+07"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="1e+08"} 1 +istio_request_bytes_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="+Inf"} 1 +istio_request_bytes_sum{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default"} 0 +istio_request_bytes_count{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default"} 1 +# HELP istio_request_duration_seconds request_duration_seconds +# TYPE istio_request_duration_seconds histogram +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.005"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.01"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.025"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.05"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.1"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.25"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.5"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="2.5"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="5"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="10"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="+Inf"} 1 +istio_request_duration_seconds_sum{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 0.001650216 +istio_request_duration_seconds_count{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="0.005"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="0.01"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="0.025"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="0.05"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="0.1"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="0.25"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="0.5"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="2.5"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="5"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="10"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="+Inf"} 1 +istio_request_duration_seconds_sum{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system"} 0.656875796 +istio_request_duration_seconds_count{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.005"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.01"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.025"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.05"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.1"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.25"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.5"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="2.5"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="5"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="10"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="+Inf"} 1 +istio_request_duration_seconds_sum{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 0.604445345 +istio_request_duration_seconds_count{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.005"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.01"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.025"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.05"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.1"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.25"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.5"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="2.5"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="5"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="10"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="+Inf"} 1 +istio_request_duration_seconds_sum{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 0.605792291 +istio_request_duration_seconds_count{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="0.005"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="0.01"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="0.025"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="0.05"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="0.1"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="0.25"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="0.5"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="2.5"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="5"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="10"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="+Inf"} 1 +istio_request_duration_seconds_sum{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system"} 0.657740289 +istio_request_duration_seconds_count{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.005"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.01"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.025"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.05"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.1"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.25"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="0.5"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="2.5"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="5"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="10"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="+Inf"} 1 +istio_request_duration_seconds_sum{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 0.005815905 +istio_request_duration_seconds_count{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="0.005"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="0.01"} 0 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="0.025"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="0.05"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="0.1"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="0.25"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="0.5"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="1"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="2.5"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="5"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="10"} 1 +istio_request_duration_seconds_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="+Inf"} 1 +istio_request_duration_seconds_sum{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default"} 0.016062491 +istio_request_duration_seconds_count{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default"} 1 +# HELP istio_requests_total requests_total +# TYPE istio_requests_total counter +istio_requests_total{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 1 +istio_requests_total{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system"} 1 +istio_requests_total{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 1 +istio_requests_total{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 1 +istio_requests_total{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system"} 1 +istio_requests_total{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 1 +istio_requests_total{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default"} 1 +# HELP istio_response_bytes response_bytes +# TYPE istio_response_bytes histogram +istio_response_bytes_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1"} 0 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="10"} 0 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="100"} 0 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1000"} 1 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="10000"} 1 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="100000"} 1 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+06"} 1 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+07"} 1 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+08"} 1 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="+Inf"} 1 +istio_response_bytes_sum{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 178 +istio_response_bytes_count{connection_security_policy="none",destination_app="details",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 1 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1"} 0 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="10"} 0 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="100"} 0 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1000"} 0 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="10000"} 1 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="100000"} 1 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1e+06"} 1 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1e+07"} 1 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1e+08"} 1 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="+Inf"} 1 +istio_response_bytes_sum{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system"} 5183 +istio_response_bytes_count{connection_security_policy="none",destination_app="productpage",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="productpage-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system"} 1 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1"} 0 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="10"} 0 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="100"} 0 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1000"} 1 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="10000"} 1 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="100000"} 1 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+06"} 1 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+07"} 1 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+08"} 1 +istio_response_bytes_bucket{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="+Inf"} 1 +istio_response_bytes_sum{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 379 +istio_response_bytes_count{connection_security_policy="none",destination_app="reviews",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v2",destination_workload="reviews-v2",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="destination",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1"} 0 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="10"} 0 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="100"} 0 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1000"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="10000"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="100000"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+06"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+07"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+08"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="+Inf"} 1 +istio_response_bytes_sum{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 379 +istio_response_bytes_count{connection_security_policy="unknown",destination_app="details",destination_principal="unknown",destination_service="reviews.default.svc.cluster.local",destination_service_name="reviews",destination_service_namespace="default",destination_version="v1",destination_workload="details-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1"} 0 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="10"} 0 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="100"} 0 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1000"} 0 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="10000"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="100000"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1e+06"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1e+07"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="1e+08"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system",le="+Inf"} 1 +istio_response_bytes_sum{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system"} 5183 +istio_response_bytes_count{connection_security_policy="unknown",destination_app="ratings",destination_principal="unknown",destination_service="productpage.default.svc.cluster.local",destination_service_name="productpage",destination_service_namespace="default",destination_version="v1",destination_workload="ratings-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="istio-ingressgateway",source_principal="unknown",source_version="unknown",source_workload="istio-ingressgateway",source_workload_namespace="istio-system"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1"} 0 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="10"} 0 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="100"} 0 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1000"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="10000"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="100000"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+06"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+07"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="1e+08"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default",le="+Inf"} 1 +istio_response_bytes_sum{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 178 +istio_response_bytes_count{connection_security_policy="unknown",destination_app="reviews",destination_principal="unknown",destination_service="details.default.svc.cluster.local",destination_service_name="details",destination_service_namespace="default",destination_version="v1",destination_workload="reviews-v1",destination_workload_namespace="default",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="productpage",source_principal="unknown",source_version="v1",source_workload="productpage-v1",source_workload_namespace="default"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="1"} 0 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="10"} 0 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="100"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="1000"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="10000"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="100000"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="1e+06"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="1e+07"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="1e+08"} 1 +istio_response_bytes_bucket{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default",le="+Inf"} 1 +istio_response_bytes_sum{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default"} 48 +istio_response_bytes_count{connection_security_policy="unknown",destination_app="sidecarInjectorWebhook",destination_principal="unknown",destination_service="ratings.default.svc.cluster.local",destination_service_name="ratings",destination_service_namespace="default",destination_version="unknown",destination_workload="istio-sidecar-injector",destination_workload_namespace="istio-system",permissive_response_code="none",permissive_response_policyid="none",reporter="source",request_protocol="http",response_code="200",response_flags="-",source_app="reviews",source_principal="unknown",source_version="v2",source_workload="reviews-v2",source_workload_namespace="default"} 1 diff --git a/x-pack/metricbeat/module/istio/mesh/_meta/testdata/docs.plain-expected.json b/x-pack/metricbeat/module/istio/mesh/_meta/testdata/docs.plain-expected.json new file mode 100644 index 00000000000..4b9c124c120 --- /dev/null +++ b/x-pack/metricbeat/module/istio/mesh/_meta/testdata/docs.plain-expected.json @@ -0,0 +1,779 @@ +[ + { + "event": { + "dataset": "istio.mesh", + "duration": 115000, + "module": "istio" + }, + "istio": { + "mesh": { + "connection": { + "security": { + "policy": "unknown" + } + }, + "destination": { + "app": "reviews", + "principal": "unknown", + "service": { + "host": "details.default.svc.cluster.local", + "name": "details", + "namespace": "default" + }, + "version": "v1", + "workload": { + "name": "reviews-v1", + "namespace": "default" + } + }, + "reporter": "source", + "request": { + "duration": { + "ms": { + "bucket": { + "+Inf": 1, + "10": 1, + "100": 1, + "1000": 1, + "10000": 1, + "25": 1, + "250": 1, + "2500": 1, + "5": 0, + "50": 1, + "500": 1, + "5000": 1 + }, + "count": 1, + "sum": 5.815905 + } + }, + "protocol": "http", + "size": { + "bytes": { + "bucket": { + "+Inf": 1, + "1": 1, + "10": 1, + "100": 1, + "1000": 1, + "10000": 1, + "100000": 1, + "1000000": 1, + "10000000": 1, + "100000000": 1 + }, + "count": 1, + "sum": 0 + } + } + }, + "requests": 1, + "response": { + "code": "200", + "size": { + "bytes": { + "bucket": { + "+Inf": 1, + "1": 0, + "10": 0, + "100": 0, + "1000": 1, + "10000": 1, + "100000": 1, + "1000000": 1, + "10000000": 1, + "100000000": 1 + }, + "count": 1, + "sum": 178 + } + } + }, + "source": { + "app": "productpage", + "principal": "unknown", + "version": "v1", + "workload": { + "name": "productpage-v1", + "namespace": "default" + } + } + } + }, + "metricset": { + "name": "mesh", + "period": 10000 + }, + "service": { + "address": "127.0.0.1:55555", + "type": "istio" + } + }, + { + "event": { + "dataset": "istio.mesh", + "duration": 115000, + "module": "istio" + }, + "istio": { + "mesh": { + "connection": { + "security": { + "policy": "none" + } + }, + "destination": { + "app": "productpage", + "principal": "unknown", + "service": { + "host": "productpage.default.svc.cluster.local", + "name": "productpage", + "namespace": "default" + }, + "version": "v1", + "workload": { + "name": "productpage-v1", + "namespace": "default" + } + }, + "reporter": "destination", + "request": { + "duration": { + "ms": { + "bucket": { + "+Inf": 1, + "10": 0, + "100": 0, + "1000": 1, + "10000": 1, + "25": 0, + "250": 0, + "2500": 1, + "5": 0, + "50": 0, + "500": 0, + "5000": 1 + }, + "count": 1, + "sum": 656.875796 + } + }, + "protocol": "http", + "size": { + "bytes": { + "bucket": { + "+Inf": 1, + "1": 1, + "10": 1, + "100": 1, + "1000": 1, + "10000": 1, + "100000": 1, + "1000000": 1, + "10000000": 1, + "100000000": 1 + }, + "count": 1, + "sum": 0 + } + } + }, + "requests": 1, + "response": { + "code": "200", + "size": { + "bytes": { + "bucket": { + "+Inf": 1, + "1": 0, + "10": 0, + "100": 0, + "1000": 0, + "10000": 1, + "100000": 1, + "1000000": 1, + "10000000": 1, + "100000000": 1 + }, + "count": 1, + "sum": 5183 + } + } + }, + "source": { + "app": "istio-ingressgateway", + "principal": "unknown", + "version": "unknown", + "workload": { + "name": "istio-ingressgateway", + "namespace": "istio-system" + } + } + } + }, + "metricset": { + "name": "mesh", + "period": 10000 + }, + "service": { + "address": "127.0.0.1:55555", + "type": "istio" + } + }, + { + "event": { + "dataset": "istio.mesh", + "duration": 115000, + "module": "istio" + }, + "istio": { + "mesh": { + "connection": { + "security": { + "policy": "unknown" + } + }, + "destination": { + "app": "sidecarInjectorWebhook", + "principal": "unknown", + "service": { + "host": "ratings.default.svc.cluster.local", + "name": "ratings", + "namespace": "default" + }, + "version": "unknown", + "workload": { + "name": "istio-sidecar-injector", + "namespace": "istio-system" + } + }, + "reporter": "source", + "request": { + "duration": { + "ms": { + "bucket": { + "+Inf": 1, + "10": 0, + "100": 1, + "1000": 1, + "10000": 1, + "25": 1, + "250": 1, + "2500": 1, + "5": 0, + "50": 1, + "500": 1, + "5000": 1 + }, + "count": 1, + "sum": 16.062491 + } + }, + "protocol": "http", + "size": { + "bytes": { + "bucket": { + "+Inf": 1, + "1": 1, + "10": 1, + "100": 1, + "1000": 1, + "10000": 1, + "100000": 1, + "1000000": 1, + "10000000": 1, + "100000000": 1 + }, + "count": 1, + "sum": 0 + } + } + }, + "requests": 1, + "response": { + "code": "200", + "size": { + "bytes": { + "bucket": { + "+Inf": 1, + "1": 0, + "10": 0, + "100": 1, + "1000": 1, + "10000": 1, + "100000": 1, + "1000000": 1, + "10000000": 1, + "100000000": 1 + }, + "count": 1, + "sum": 48 + } + } + }, + "source": { + "app": "reviews", + "principal": "unknown", + "version": "v2", + "workload": { + "name": "reviews-v2", + "namespace": "default" + } + } + } + }, + "metricset": { + "name": "mesh", + "period": 10000 + }, + "service": { + "address": "127.0.0.1:55555", + "type": "istio" + } + }, + { + "event": { + "dataset": "istio.mesh", + "duration": 115000, + "module": "istio" + }, + "istio": { + "mesh": { + "connection": { + "security": { + "policy": "none" + } + }, + "destination": { + "app": "details", + "principal": "unknown", + "service": { + "host": "details.default.svc.cluster.local", + "name": "details", + "namespace": "default" + }, + "version": "v1", + "workload": { + "name": "details-v1", + "namespace": "default" + } + }, + "reporter": "destination", + "request": { + "duration": { + "ms": { + "bucket": { + "+Inf": 1, + "10": 1, + "100": 1, + "1000": 1, + "10000": 1, + "25": 1, + "250": 1, + "2500": 1, + "5": 1, + "50": 1, + "500": 1, + "5000": 1 + }, + "count": 1, + "sum": 1.650216 + } + }, + "protocol": "http", + "size": { + "bytes": { + "bucket": { + "+Inf": 1, + "1": 1, + "10": 1, + "100": 1, + "1000": 1, + "10000": 1, + "100000": 1, + "1000000": 1, + "10000000": 1, + "100000000": 1 + }, + "count": 1, + "sum": 0 + } + } + }, + "requests": 1, + "response": { + "code": "200", + "size": { + "bytes": { + "bucket": { + "+Inf": 1, + "1": 0, + "10": 0, + "100": 0, + "1000": 1, + "10000": 1, + "100000": 1, + "1000000": 1, + "10000000": 1, + "100000000": 1 + }, + "count": 1, + "sum": 178 + } + } + }, + "source": { + "app": "productpage", + "principal": "unknown", + "version": "v1", + "workload": { + "name": "productpage-v1", + "namespace": "default" + } + } + } + }, + "metricset": { + "name": "mesh", + "period": 10000 + }, + "service": { + "address": "127.0.0.1:55555", + "type": "istio" + } + }, + { + "event": { + "dataset": "istio.mesh", + "duration": 115000, + "module": "istio" + }, + "istio": { + "mesh": { + "connection": { + "security": { + "policy": "none" + } + }, + "destination": { + "app": "reviews", + "principal": "unknown", + "service": { + "host": "reviews.default.svc.cluster.local", + "name": "reviews", + "namespace": "default" + }, + "version": "v2", + "workload": { + "name": "reviews-v2", + "namespace": "default" + } + }, + "reporter": "destination", + "request": { + "duration": { + "ms": { + "bucket": { + "+Inf": 1, + "10": 0, + "100": 0, + "1000": 1, + "10000": 1, + "25": 0, + "250": 0, + "2500": 1, + "5": 0, + "50": 0, + "500": 0, + "5000": 1 + }, + "count": 1, + "sum": 604.445345 + } + }, + "protocol": "http", + "size": { + "bytes": { + "bucket": { + "+Inf": 1, + "1": 1, + "10": 1, + "100": 1, + "1000": 1, + "10000": 1, + "100000": 1, + "1000000": 1, + "10000000": 1, + "100000000": 1 + }, + "count": 1, + "sum": 0 + } + } + }, + "requests": 1, + "response": { + "code": "200", + "size": { + "bytes": { + "bucket": { + "+Inf": 1, + "1": 0, + "10": 0, + "100": 0, + "1000": 1, + "10000": 1, + "100000": 1, + "1000000": 1, + "10000000": 1, + "100000000": 1 + }, + "count": 1, + "sum": 379 + } + } + }, + "source": { + "app": "productpage", + "principal": "unknown", + "version": "v1", + "workload": { + "name": "productpage-v1", + "namespace": "default" + } + } + } + }, + "metricset": { + "name": "mesh", + "period": 10000 + }, + "service": { + "address": "127.0.0.1:55555", + "type": "istio" + } + }, + { + "event": { + "dataset": "istio.mesh", + "duration": 115000, + "module": "istio" + }, + "istio": { + "mesh": { + "connection": { + "security": { + "policy": "unknown" + } + }, + "destination": { + "app": "details", + "principal": "unknown", + "service": { + "host": "reviews.default.svc.cluster.local", + "name": "reviews", + "namespace": "default" + }, + "version": "v1", + "workload": { + "name": "details-v1", + "namespace": "default" + } + }, + "reporter": "source", + "request": { + "duration": { + "ms": { + "bucket": { + "+Inf": 1, + "10": 0, + "100": 0, + "1000": 1, + "10000": 1, + "25": 0, + "250": 0, + "2500": 1, + "5": 0, + "50": 0, + "500": 0, + "5000": 1 + }, + "count": 1, + "sum": 605.792291 + } + }, + "protocol": "http", + "size": { + "bytes": { + "bucket": { + "+Inf": 1, + "1": 1, + "10": 1, + "100": 1, + "1000": 1, + "10000": 1, + "100000": 1, + "1000000": 1, + "10000000": 1, + "100000000": 1 + }, + "count": 1, + "sum": 0 + } + } + }, + "requests": 1, + "response": { + "code": "200", + "size": { + "bytes": { + "bucket": { + "+Inf": 1, + "1": 0, + "10": 0, + "100": 0, + "1000": 1, + "10000": 1, + "100000": 1, + "1000000": 1, + "10000000": 1, + "100000000": 1 + }, + "count": 1, + "sum": 379 + } + } + }, + "source": { + "app": "productpage", + "principal": "unknown", + "version": "v1", + "workload": { + "name": "productpage-v1", + "namespace": "default" + } + } + } + }, + "metricset": { + "name": "mesh", + "period": 10000 + }, + "service": { + "address": "127.0.0.1:55555", + "type": "istio" + } + }, + { + "event": { + "dataset": "istio.mesh", + "duration": 115000, + "module": "istio" + }, + "istio": { + "mesh": { + "connection": { + "security": { + "policy": "unknown" + } + }, + "destination": { + "app": "ratings", + "principal": "unknown", + "service": { + "host": "productpage.default.svc.cluster.local", + "name": "productpage", + "namespace": "default" + }, + "version": "v1", + "workload": { + "name": "ratings-v1", + "namespace": "default" + } + }, + "reporter": "source", + "request": { + "duration": { + "ms": { + "bucket": { + "+Inf": 1, + "10": 0, + "100": 0, + "1000": 1, + "10000": 1, + "25": 0, + "250": 0, + "2500": 1, + "5": 0, + "50": 0, + "500": 0, + "5000": 1 + }, + "count": 1, + "sum": 657.7402890000001 + } + }, + "protocol": "http", + "size": { + "bytes": { + "bucket": { + "+Inf": 1, + "1": 1, + "10": 1, + "100": 1, + "1000": 1, + "10000": 1, + "100000": 1, + "1000000": 1, + "10000000": 1, + "100000000": 1 + }, + "count": 1, + "sum": 0 + } + } + }, + "requests": 1, + "response": { + "code": "200", + "size": { + "bytes": { + "bucket": { + "+Inf": 1, + "1": 0, + "10": 0, + "100": 0, + "1000": 0, + "10000": 1, + "100000": 1, + "1000000": 1, + "10000000": 1, + "100000000": 1 + }, + "count": 1, + "sum": 5183 + } + } + }, + "source": { + "app": "istio-ingressgateway", + "principal": "unknown", + "version": "unknown", + "workload": { + "name": "istio-ingressgateway", + "namespace": "istio-system" + } + } + } + }, + "metricset": { + "name": "mesh", + "period": 10000 + }, + "service": { + "address": "127.0.0.1:55555", + "type": "istio" + } + } +] \ No newline at end of file diff --git a/x-pack/metricbeat/module/istio/mesh/mesh.go b/x-pack/metricbeat/module/istio/mesh/mesh.go new file mode 100644 index 00000000000..e375d5ce728 --- /dev/null +++ b/x-pack/metricbeat/module/istio/mesh/mesh.go @@ -0,0 +1,60 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +package mesh + +import ( + "github.com/elastic/beats/metricbeat/helper/prometheus" + "github.com/elastic/beats/metricbeat/mb" + "github.com/elastic/beats/metricbeat/mb/parse" +) + +const ( + defaultScheme = "http" + defaultPath = "/metrics" +) + +var ( + hostParser = parse.URLHostParserBuilder{ + DefaultScheme: defaultScheme, + DefaultPath: defaultPath, + }.Build() +) + +var mapping = &prometheus.MetricsMapping{ + Metrics: map[string]prometheus.MetricMap{ + "istio_requests_total": prometheus.Metric("requests"), + "istio_request_duration_seconds": prometheus.Metric("request.duration.ms", prometheus.OpMultiplyBuckets(1000)), + "istio_request_bytes": prometheus.Metric("request.size.bytes"), + "istio_response_bytes": prometheus.Metric("response.size.bytes"), + }, + + Labels: map[string]prometheus.LabelMap{ + "instance": prometheus.KeyLabel("instance"), + "job": prometheus.KeyLabel("job"), + "source_workload": prometheus.KeyLabel("source.workload.name"), + "source_workload_namespace": prometheus.KeyLabel("source.workload.namespace"), + "source_principal": prometheus.KeyLabel("source.principal"), + "source_app": prometheus.KeyLabel("source.app"), + "source_version": prometheus.KeyLabel("source.version"), + "destination_workload": prometheus.KeyLabel("destination.workload.name"), + "destination_workload_namespace": prometheus.KeyLabel("destination.workload.namespace"), + "destination_principal": prometheus.KeyLabel("destination.principal"), + "destination_app": prometheus.KeyLabel("destination.app"), + "destination_version": prometheus.KeyLabel("destination.version"), + "destination_service": prometheus.KeyLabel("destination.service.host"), + "destination_service_name": prometheus.KeyLabel("destination.service.name"), + "destination_service_namespace": prometheus.KeyLabel("destination.service.namespace"), + "reporter": prometheus.KeyLabel("reporter"), + "request_protocol": prometheus.KeyLabel("request.protocol"), + "response_code": prometheus.KeyLabel("response.code"), + "connection_security_policy": prometheus.KeyLabel("connection.security.policy"), + }, +} + +func init() { + mb.Registry.MustAddMetricSet("istio", "mesh", + prometheus.MetricSetBuilder(mapping), + mb.WithHostParser(hostParser)) +} diff --git a/x-pack/metricbeat/module/istio/mesh/mesh_test.go b/x-pack/metricbeat/module/istio/mesh/mesh_test.go new file mode 100644 index 00000000000..801a2330992 --- /dev/null +++ b/x-pack/metricbeat/module/istio/mesh/mesh_test.go @@ -0,0 +1,19 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +// +build !integration + +package mesh + +import ( + "testing" + + mbtest "github.com/elastic/beats/metricbeat/mb/testing" + + _ "github.com/elastic/beats/x-pack/metricbeat/module/istio" +) + +func TestData(t *testing.T) { + mbtest.TestDataFiles(t, "istio", "mesh") +} diff --git a/x-pack/metricbeat/module/istio/module.yaml b/x-pack/metricbeat/module/istio/module.yaml new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/x-pack/metricbeat/module/istio/module.yaml @@ -0,0 +1 @@ + diff --git a/x-pack/metricbeat/module/oracle/connection.go b/x-pack/metricbeat/module/oracle/connection.go index b418c4ac5f8..96add9ced08 100644 --- a/x-pack/metricbeat/module/oracle/connection.go +++ b/x-pack/metricbeat/module/oracle/connection.go @@ -7,7 +7,7 @@ package oracle import ( "database/sql" - "gopkg.in/goracle.v2" + "github.com/godror/godror" "github.com/elastic/beats/metricbeat/mb" "github.com/elastic/beats/metricbeat/mb/parse" @@ -37,7 +37,7 @@ func init() { // NewConnection returns a connection already established with Oracle func NewConnection(c *ConnectionDetails) (*sql.DB, error) { - params, err := goracle.ParseConnString(c.Hosts[0]) + params, err := godror.ParseConnString(c.Hosts[0]) if err != nil { return nil, errors.Wrap(err, "error trying to parse connection string in field 'hosts'") } @@ -54,7 +54,7 @@ func NewConnection(c *ConnectionDetails) (*sql.DB, error) { return nil, errors.New("a user with DBA permissions are required, check your connection details on field `hosts`") } - db, err := sql.Open("goracle", params.StringWithPassword()) + db, err := sql.Open("godror", params.StringWithPassword()) if err != nil { return nil, errors.Wrap(err, "could not open database") } diff --git a/x-pack/metricbeat/module/oracle/performance/metricset_test.go b/x-pack/metricbeat/module/oracle/performance/metricset_test.go index b6182b5b41d..80d16a4e495 100644 --- a/x-pack/metricbeat/module/oracle/performance/metricset_test.go +++ b/x-pack/metricbeat/module/oracle/performance/metricset_test.go @@ -9,7 +9,7 @@ package performance import ( "testing" - _ "gopkg.in/goracle.v2" + _ "github.com/godror/godror" "github.com/elastic/beats/libbeat/common" mbtest "github.com/elastic/beats/metricbeat/mb/testing" diff --git a/x-pack/metricbeat/module/oracle/tablespace/metricset_test.go b/x-pack/metricbeat/module/oracle/tablespace/metricset_test.go index a7934647826..f0bb4b672d8 100644 --- a/x-pack/metricbeat/module/oracle/tablespace/metricset_test.go +++ b/x-pack/metricbeat/module/oracle/tablespace/metricset_test.go @@ -9,7 +9,7 @@ package tablespace import ( "testing" - _ "gopkg.in/goracle.v2" + _ "github.com/godror/godror" "github.com/elastic/beats/libbeat/tests/compose" mbtest "github.com/elastic/beats/metricbeat/mb/testing" diff --git a/x-pack/metricbeat/module/oracle/testing.go b/x-pack/metricbeat/module/oracle/testing.go index 06c87b10b56..5ffe9cd83f4 100644 --- a/x-pack/metricbeat/module/oracle/testing.go +++ b/x-pack/metricbeat/module/oracle/testing.go @@ -8,12 +8,12 @@ import ( "fmt" "os" - "gopkg.in/goracle.v2" + "github.com/godror/godror" ) // GetOracleConnectionDetails return a valid SID to use for testing func GetOracleConnectionDetails(host string) string { - params := goracle.ConnectionParams{ + params := godror.ConnectionParams{ SID: fmt.Sprintf("%s/%s", host, GetOracleEnvServiceName()), Username: GetOracleEnvUsername(), Password: GetOracleEnvPassword(), diff --git a/x-pack/metricbeat/module/sql/_meta/config.yml b/x-pack/metricbeat/module/sql/_meta/config.yml index 92b5f388221..5c6a419e77b 100644 --- a/x-pack/metricbeat/module/sql/_meta/config.yml +++ b/x-pack/metricbeat/module/sql/_meta/config.yml @@ -2,9 +2,8 @@ metricsets: - query period: 10s - hosts: ["localhost"] + hosts: ["user=myuser password=mypassword dbname=mydb sslmode=disable"] driver: "postgres" - datasource: "user=myuser password=mypassword dbname=mydb sslmode=disable" sql_query: "select now()" diff --git a/x-pack/metricbeat/module/sql/_meta/docs.asciidoc b/x-pack/metricbeat/module/sql/_meta/docs.asciidoc index d7bb818a58b..f22edf1fa20 100644 --- a/x-pack/metricbeat/module/sql/_meta/docs.asciidoc +++ b/x-pack/metricbeat/module/sql/_meta/docs.asciidoc @@ -1,3 +1,3 @@ -This is the sql module that fetches metrics from a SQL database. You can define driver, datasource and SQL query. +This is the sql module that fetches metrics from a SQL database. You can define driver and SQL query. diff --git a/x-pack/metricbeat/module/sql/_meta/fields.yml b/x-pack/metricbeat/module/sql/_meta/fields.yml index b27abd8896a..81a3dfb3df5 100644 --- a/x-pack/metricbeat/module/sql/_meta/fields.yml +++ b/x-pack/metricbeat/module/sql/_meta/fields.yml @@ -2,10 +2,26 @@ title: "sql" release: beta description: > - sql module + SQL module fetches metrics from a SQL database fields: - name: sql type: group - description: > - `sql` fetches metrics from a SQL database fields: + - name: driver + type: keyword + description: > + Driver used to execute the query. + - name: query + type: keyword + description: > + Query executed to collect metrics. + - name: metrics.numeric.* + type: object + object_type: double + description: > + Numeric metrics collected. + - name: metrics.string.* + type: object + object_type: keyword + description: > + Non-numeric values collected. diff --git a/x-pack/metricbeat/module/sql/docker-compose.yml b/x-pack/metricbeat/module/sql/docker-compose.yml new file mode 100644 index 00000000000..a053c322d30 --- /dev/null +++ b/x-pack/metricbeat/module/sql/docker-compose.yml @@ -0,0 +1,12 @@ +version: '2.3' + +services: + mysql: + extends: + file: ../../../../metricbeat/module/mysql/docker-compose.yml + service: mysql + + postgresql: + extends: + file: ../../../../metricbeat/module/postgresql/docker-compose.yml + service: postgresql diff --git a/x-pack/metricbeat/module/sql/fields.go b/x-pack/metricbeat/module/sql/fields.go index 87127a1c2f2..cefc5b3c29b 100644 --- a/x-pack/metricbeat/module/sql/fields.go +++ b/x-pack/metricbeat/module/sql/fields.go @@ -19,5 +19,5 @@ func init() { // AssetSql returns asset data. // This is the base64 encoded gzipped contents of module/sql. func AssetSql() string { - return "eJykkk2O4jAUhPc5RYnlSHCALGY1yxESmgMMjl2AGycm9jPduX3L+UEQpZGaruWruOqL/dY4sysRW1cAYsWxxCq2blUAgY4qskRFUQVgGHWwF7G+KfG7AJDPofYmORbAwdKZWPbGGo2qOQVnSXdhiWPw6TJOFvKy9rF1exwo+sSImhKsjjgEX0Ph3+4vjBJVqUiMR+5777vbxNDdpksEWfO/nPQFXdY8eA5wD2GCvTI8WBPJmd27D2bmPenN+tPnIUUaiAc/qJMQcuKAtVmkmBP/EGKX46bunkN756hleq5lislsUs1g9ebXIpGv3qhlZg3D/8MXxqeq37hvIG+Hzts+jcA0z1GjBNscXyZ96Xa3vlmPV4SrcokPtJ8BAAD//zTX/E8=" + return "eJykkkFuwjAQRfc5xRfLSnAAL7rqskJCPUDl2B9wcWJij2lz+4okRqlSpKJ6+T0z72XiNU7sFVLnK0CceCqsUudXFRDpqRMVaoquAMtkojuLC63CcwUAb7tXNMFmT+wp5siEhhKdSdjH0EAPFVaLrnViBewdvU1qaF6j1Q0L/HqkP1PhEEM+T8m8ft5jo7sw3uLSemL/GaKd5b9Il/MyzEBOtJAAftFkIeRIdJmx3yyoQ/w/6O46orAGrgne00hZ3JJaLtrcMDqzeVoYhPqDRmbxGLyPtzbk2vNvetuRcfuLkxztfa0k0bWHh60e2to2tOvp83HRPvOO2c8n+x0AAP//MiXQYA==" } diff --git a/x-pack/metricbeat/module/sql/query/_meta/data.json b/x-pack/metricbeat/module/sql/query/_meta/data.json index 1a92415be34..799c66fe7bc 100644 --- a/x-pack/metricbeat/module/sql/query/_meta/data.json +++ b/x-pack/metricbeat/module/sql/query/_meta/data.json @@ -1,26 +1,30 @@ { - "@timestamp":"2016-05-23T08:05:34.853Z", - "beat":{ - "hostname":"beathost", - "name":"beathost" + "@timestamp": "2017-10-12T08:05:34.853Z", + "event": { + "dataset": "sql.query", + "duration": 115000, + "module": "sql" }, - "metricset":{ - "host":"localhost", - "module":"sql", - "name":"query", - "rtt":44269 + "metricset": { + "name": "query", + "period": 10000 }, - "sql":{ - "metrics":{ - "numeric":{ - "mynumericfield":1 - }, - "string":{ - "mystringfield":"abc" - } + "service": { + "address": "172.22.0.3:3306", + "type": "sql" + }, + "sql": { + "driver": "mysql", + "metrics": { + "numeric": { + "table_rows": 6 + }, + "string": { + "engine": "InnoDB", + "table_name": "sys_config", + "table_schema": "sys" + } }, - "driver":"postgres", - "query":"select * from mytable" - }, - "type":"metricsets" + "query": "select table_schema, table_name, engine, table_rows from information_schema.tables where table_rows \u003e 0;" + } } \ No newline at end of file diff --git a/x-pack/metricbeat/module/sql/query/_meta/data_postgres.json b/x-pack/metricbeat/module/sql/query/_meta/data_postgres.json new file mode 100644 index 00000000000..0f2db40c5b1 --- /dev/null +++ b/x-pack/metricbeat/module/sql/query/_meta/data_postgres.json @@ -0,0 +1,45 @@ +{ + "@timestamp": "2017-10-12T08:05:34.853Z", + "event": { + "dataset": "sql.query", + "duration": 115000, + "module": "sql" + }, + "metricset": { + "name": "query", + "period": 10000 + }, + "service": { + "address": "172.22.0.2:5432", + "type": "sql" + }, + "sql": { + "driver": "postgres", + "metrics": { + "numeric": { + "blk_read_time": 0, + "blk_write_time": 0, + "blks_hit": 1923, + "blks_read": 111, + "conflicts": 0, + "datid": 12379, + "deadlocks": 0, + "numbackends": 1, + "temp_bytes": 0, + "temp_files": 0, + "tup_deleted": 0, + "tup_fetched": 1249, + "tup_inserted": 0, + "tup_returned": 1356, + "tup_updated": 0, + "xact_commit": 18, + "xact_rollback": 0 + }, + "string": { + "datname": "postgres", + "stats_reset": "2020-01-21 11:23:56.53" + } + }, + "query": "select * from pg_stat_database" + } +} \ No newline at end of file diff --git a/x-pack/metricbeat/module/sql/query/_meta/fields.yml b/x-pack/metricbeat/module/sql/query/_meta/fields.yml index b6e7eb58132..8033a27f5ac 100644 --- a/x-pack/metricbeat/module/sql/query/_meta/fields.yml +++ b/x-pack/metricbeat/module/sql/query/_meta/fields.yml @@ -1,24 +1 @@ -- name: query - type: group - release: beta - description: > - query - fields: - - name: driver - type: keyword - description: > - Driver used to execute the query. - - name: query - type: keyword - description: > - Query executed to collect metrics. - - name: metrics.numeric.* - type: object - object_type: double - description: > - Numeric metrics collected. - - name: metrics.string.* - type: object - object_type: keyword - description: > - Non-numeric values collected. +- release: beta diff --git a/x-pack/metricbeat/module/sql/query/dsn.go b/x-pack/metricbeat/module/sql/query/dsn.go new file mode 100644 index 00000000000..2a472c3fbe5 --- /dev/null +++ b/x-pack/metricbeat/module/sql/query/dsn.go @@ -0,0 +1,42 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +package query + +import ( + "net/url" + + "github.com/go-sql-driver/mysql" + + "github.com/elastic/beats/metricbeat/mb" +) + +// ParseDSN tries to parse the host +func ParseDSN(mod mb.Module, host string) (mb.HostData, error) { + // TODO: Add support for `username` and `password` as module options + + sanitized := sanitize(host) + + return mb.HostData{ + URI: host, + SanitizedURI: sanitized, + Host: sanitized, + }, nil +} + +func sanitize(host string) string { + // Host is a standard URL + if url, err := url.Parse(host); err == nil && len(url.Host) > 0 { + return url.Host + } + + // Host is a MySQL DSN + if config, err := mysql.ParseDSN(host); err == nil { + return config.Addr + } + + // TODO: Add support for PostgreSQL connection strings and other formats + + return "(redacted)" +} diff --git a/x-pack/metricbeat/module/sql/query/query.go b/x-pack/metricbeat/module/sql/query/query.go index 884df1b9df9..c3507cd964e 100644 --- a/x-pack/metricbeat/module/sql/query/query.go +++ b/x-pack/metricbeat/module/sql/query/query.go @@ -10,13 +10,12 @@ import ( "strings" "time" + "github.com/jmoiron/sqlx" "github.com/pkg/errors" "github.com/elastic/beats/libbeat/common" "github.com/elastic/beats/libbeat/common/cfgwarn" "github.com/elastic/beats/metricbeat/mb" - - "github.com/jmoiron/sqlx" ) // init registers the MetricSet with the central registry as soon as the program @@ -24,7 +23,9 @@ import ( // the MetricSet for each host defined in the module's configuration. After the // MetricSet has been created then Fetch will begin to be called periodically. func init() { - mb.Registry.MustAddMetricSet("sql", "query", New) + mb.Registry.MustAddMetricSet("sql", "query", New, + mb.WithHostParser(ParseDSN), + ) } // MetricSet holds any configuration or state information. It must implement @@ -33,9 +34,8 @@ func init() { // interface methods except for Fetch. type MetricSet struct { mb.BaseMetricSet - Driver string - Datasource string - Query string + Driver string + Query string } // New creates a new instance of the MetricSet. New is responsible for unpacking @@ -44,9 +44,8 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) { cfgwarn.Beta("The sql query metricset is beta.") config := struct { - Driver string `config:"driver"` - Datasource string `config:"datasource"` - Query string `config:"sql_query"` + Driver string `config:"driver" validate:"nonzero,required"` + Query string `config:"sql_query" validate:"nonzero,required"` }{} if err := base.Module().UnpackConfig(&config); err != nil { @@ -56,7 +55,6 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) { return &MetricSet{ BaseMetricSet: base, Driver: config.Driver, - Datasource: config.Datasource, Query: config.Query, }, nil } @@ -65,7 +63,7 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) { // format. It publishes the event which is then forwarded to the output. In case // of an error set the Error field of mb.Event or simply call report.Error(). func (m *MetricSet) Fetch(report mb.ReporterV2) error { - db, err := sqlx.Open(m.Driver, m.Datasource) + db, err := sqlx.Open(m.Driver, m.HostData().URI) if err != nil { return errors.Wrap(err, "error opening connection") } @@ -98,10 +96,6 @@ func (m *MetricSet) Fetch(report mb.ReporterV2) error { vals[i] = new(interface{}) } - numericValue := common.MapStr{} - - stringValue := common.MapStr{} - for rows.Next() { err = rows.Scan(vals...) if err != nil { @@ -109,30 +103,32 @@ func (m *MetricSet) Fetch(report mb.ReporterV2) error { continue } - data := common.MapStr{ - "metrics": common.MapStr{}, - } - data.Put("driver", m.Driver) - data.Put("query", m.Query) + numericMetrics := common.MapStr{} + stringMetrics := common.MapStr{} for i := 0; i < len(vals); i++ { - dataMetrics := data["metrics"].(common.MapStr) - value := getValue(vals[i].(*interface{})) - num, err := strconv.ParseFloat(value, 64) if err == nil { - numericValue.Put(cols[i], num) - dataMetrics.Put("numeric", numericValue) + numericMetrics[cols[i]] = num } else { - stringValue.Put(cols[i], value) - dataMetrics.Put("string", stringValue) + stringMetrics[cols[i]] = value } - report.Event(mb.Event{ - RootFields: common.MapStr{"sql": data}, - }) } + + report.Event(mb.Event{ + RootFields: common.MapStr{ + "sql": common.MapStr{ + "driver": m.Driver, + "query": m.Query, + "metrics": common.MapStr{ + "numeric": numericMetrics, + "string": stringMetrics, + }, + }, + }, + }) } if rows.Err() != nil { diff --git a/x-pack/metricbeat/module/sql/query/query_integration_test.go b/x-pack/metricbeat/module/sql/query/query_integration_test.go new file mode 100644 index 00000000000..d7e04f23c40 --- /dev/null +++ b/x-pack/metricbeat/module/sql/query/query_integration_test.go @@ -0,0 +1,126 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +// +build integration + +package query + +import ( + "fmt" + "net" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + // Drivers + _ "github.com/go-sql-driver/mysql" + _ "github.com/lib/pq" + + "github.com/elastic/beats/libbeat/beat" + "github.com/elastic/beats/libbeat/tests/compose" + "github.com/elastic/beats/metricbeat/mb" + mbtest "github.com/elastic/beats/metricbeat/mb/testing" + "github.com/elastic/beats/metricbeat/module/mysql" + "github.com/elastic/beats/metricbeat/module/postgresql" +) + +type testFetchConfig struct { + Driver string + Query string + Host string + + Assertion func(t *testing.T, event beat.Event) +} + +func TestMySQL(t *testing.T) { + service := compose.EnsureUp(t, "mysql") + config := testFetchConfig{ + Driver: "mysql", + Query: "select table_schema, table_name, engine, table_rows from information_schema.tables where table_rows > 0;", + Host: mysql.GetMySQLEnvDSN(service.Host()), + Assertion: assertFieldNotContains("service.address", ":test@"), + } + + t.Run("fetch", func(t *testing.T) { + testFetch(t, config) + }) + + t.Run("data", func(t *testing.T) { + testData(t, config, "") + }) +} + +func TestPostgreSQL(t *testing.T) { + service := compose.EnsureUp(t, "postgresql") + host, port, err := net.SplitHostPort(service.Host()) + require.NoError(t, err) + + user := postgresql.GetEnvUsername() + password := postgresql.GetEnvPassword() + + config := testFetchConfig{ + Driver: "postgres", + Query: "select * from pg_stat_database", + Host: fmt.Sprintf("user=%s password=%s sslmode=disable host=%s port=%s", user, password, host, port), + Assertion: assertFieldNotContains("service.address", "password="+password), + } + + t.Run("fetch", func(t *testing.T) { + testFetch(t, config) + }) + + config = testFetchConfig{ + Driver: "postgres", + Query: "select * from pg_stat_database", + Host: fmt.Sprintf("postgres://%s:%s@%s:%s/?sslmode=disable", user, password, host, port), + Assertion: assertFieldNotContains("service.address", ":"+password+"@"), + } + + t.Run("fetch with URL", func(t *testing.T) { + testFetch(t, config) + }) + + t.Run("data", func(t *testing.T) { + testData(t, config, "./_meta/data_postgres.json") + }) +} + +func testFetch(t *testing.T, cfg testFetchConfig) { + m := mbtest.NewFetcher(t, getConfig(cfg)) + events, errs := m.FetchEvents() + require.Empty(t, errs) + require.NotEmpty(t, events) + t.Logf("%s/%s event: %+v", m.Module().Name(), m.Name(), events[0]) + + if cfg.Assertion != nil { + for _, event := range events { + cfg.Assertion(t, m.StandardizeEvent(event, mb.AddMetricSetInfo)) + } + } +} + +func testData(t *testing.T, cfg testFetchConfig, postfix string) { + m := mbtest.NewFetcher(t, getConfig(cfg)) + m.WriteEvents(t, postfix) +} + +func getConfig(cfg testFetchConfig) map[string]interface{} { + return map[string]interface{}{ + "module": "sql", + "metricsets": []string{"query"}, + "hosts": []string{cfg.Host}, + "driver": cfg.Driver, + "sql_query": cfg.Query, + } +} + +func assertFieldNotContains(field, s string) func(t *testing.T, event beat.Event) { + return func(t *testing.T, event beat.Event) { + value, err := event.GetValue(field) + assert.NoError(t, err) + require.NotEmpty(t, value.(string)) + require.NotContains(t, value.(string), s) + } +} diff --git a/x-pack/metricbeat/module/sql/test_sql.py b/x-pack/metricbeat/module/sql/test_sql.py new file mode 100644 index 00000000000..8a18791b386 --- /dev/null +++ b/x-pack/metricbeat/module/sql/test_sql.py @@ -0,0 +1,41 @@ +import os +import sys +import unittest + +sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system')) +from xpack_metricbeat import XPackTest, metricbeat + + +class Test(XPackTest): + + COMPOSE_SERVICES = ['mysql'] + + @unittest.skipUnless(metricbeat.INTEGRATION_TESTS, "integration test") + def test_query(self): + """ + sql custom query test + """ + self.render_config_template(modules=[{ + "name": "sql", + "metricsets": ["query"], + "hosts": self.get_hosts(), + "period": "5s", + "additional_content": """ + driver: mysql + sql_query: 'select table_schema, table_name, engine, table_rows from information_schema.tables where table_rows > 0'""" + }]) + proc = self.start_beat(home=self.beat_path) + self.wait_until(lambda: self.output_lines() > 0) + proc.check_kill_and_wait() + self.assert_no_logged_warnings() + + output = self.read_output_json() + self.assertGreater(len(output), 0) + + for evt in output: + self.assert_fields_are_documented(evt) + self.assertIn("sql", evt.keys(), evt) + self.assertIn("query", evt["sql"].keys(), evt) + + def get_hosts(self): + return ['root:test@tcp({})/'.format(self.compose_host())] diff --git a/x-pack/metricbeat/module/statsd/_meta/fields.yml b/x-pack/metricbeat/module/statsd/_meta/fields.yml index 7d26b197b23..a9fe3e8e931 100644 --- a/x-pack/metricbeat/module/statsd/_meta/fields.yml +++ b/x-pack/metricbeat/module/statsd/_meta/fields.yml @@ -4,15 +4,18 @@ Statsd module release: beta fields: - - name: statsd.*.count - type: object - object_type: long - object_type_mapping_type: "long" - description: > - Statsd counters - - name: statsd.*.* - type: object - object_type: float - object_type_mapping_type: "*" - description: > - Statsd metrics \ No newline at end of file + - name: statsd + type: group + fields: + - name: '*.count' + type: object + object_type: long + object_type_mapping_type: "long" + description: > + Statsd counters + - name: '*.*' + type: object + object_type: float + object_type_mapping_type: "*" + description: > + Statsd metrics diff --git a/x-pack/metricbeat/module/statsd/fields.go b/x-pack/metricbeat/module/statsd/fields.go index a15eac3cb38..4cc1e0c02a8 100644 --- a/x-pack/metricbeat/module/statsd/fields.go +++ b/x-pack/metricbeat/module/statsd/fields.go @@ -19,5 +19,5 @@ func init() { // AssetStatsd returns asset data. // This is the base64 encoded gzipped contents of module/statsd. func AssetStatsd() string { - return "eJyMkD2OhSAURntW8YXSRBdAMZuYBRiEq2GGv8C1cPeTQX158VlY8p2T3BN6/NKmUFlztQJgx54U5HcbpAAsVVNcZpeiwpcAgB0iJLt6EkAhT7qSwkSsBTA78raq5vaIOtB5YegGk9bIDQG8ZVJI0w+Zc9of4058isvnPgads4vLIcl/Sx7aTe1bcbtNpd6XdQ+rZp/0Dbhmdc+aAnFxpr7m/vKdfwEAAP//q4R+AQ==" + return "eJyUkTtuxiAQhHtOMaL5JUvOAShyiRzAwrC2SHgJ1oVvH/kVkcgpvOV8s+Jb0eOLVoXKmqsVADv2pCA/9kAKwFI1xWV2KSq8CwA4IEKyiycBFPKkKymMxFoAkyNvq9q7PaIO1LywDa+ZFOaSlnwm7Uq79ureTFoiv37ItZ3GTzLcxEcwHNSnON+zIeicXZzPotyasqne3HvNefcuRKXeyXZPRSef9D/wr2n3TDMQF2day9//9B0AAP//sz6NDg==" } diff --git a/x-pack/metricbeat/modules.d/istio.yml.disabled b/x-pack/metricbeat/modules.d/istio.yml.disabled new file mode 100644 index 00000000000..feeefdffe2b --- /dev/null +++ b/x-pack/metricbeat/modules.d/istio.yml.disabled @@ -0,0 +1,7 @@ +# Module: istio +# Docs: https://www.elastic.co/guide/en/beats/metricbeat/master/metricbeat-module-istio.html + +- module: istio + metricsets: ["mesh"] + period: 10s + hosts: ["localhost:42422"] diff --git a/x-pack/metricbeat/modules.d/sql.yml.disabled b/x-pack/metricbeat/modules.d/sql.yml.disabled index ab839d64f49..31f15547123 100644 --- a/x-pack/metricbeat/modules.d/sql.yml.disabled +++ b/x-pack/metricbeat/modules.d/sql.yml.disabled @@ -5,9 +5,8 @@ metricsets: - query period: 10s - hosts: ["localhost"] + hosts: ["user=myuser password=mypassword dbname=mydb sslmode=disable"] driver: "postgres" - datasource: "user=myuser password=mypassword dbname=mydb sslmode=disable" sql_query: "select now()" diff --git a/x-pack/winlogbeat/winlogbeat.reference.yml b/x-pack/winlogbeat/winlogbeat.reference.yml index 767e5bd03d5..d7b25e5c204 100644 --- a/x-pack/winlogbeat/winlogbeat.reference.yml +++ b/x-pack/winlogbeat/winlogbeat.reference.yml @@ -411,9 +411,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # List of root certificates for HTTPS server verifications #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] @@ -503,9 +503,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -676,9 +676,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Certificate for SSL client authentication #ssl.certificate: "/etc/pki/client/cert.pem" @@ -788,9 +788,9 @@ output.elasticsearch: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # Optional SSL configuration options. SSL is off by default. # List of root certificates for HTTPS server verifications @@ -1013,7 +1013,7 @@ setup.template.settings: #setup.ilm.pattern: "{now/d}-000001" # Set the lifecycle policy name. The default policy name is -# 'winlogbeat-%{[agent.version]}'. +# 'winlogbeat'. #setup.ilm.policy_name: "mypolicy" # The path to a JSON file that contains a lifecycle policy configuration. Used @@ -1057,9 +1057,9 @@ setup.kibana: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -1233,9 +1233,9 @@ logging.files: # `full`. #ssl.verification_mode: full - # List of supported/valid TLS versions. By default all TLS versions from 1.0 up to - # 1.2 are enabled. - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] + # List of supported/valid TLS versions. By default all TLS versions from 1.1 + # up to 1.3 are enabled. + #ssl.supported_protocols: [TLSv1.1, TLSv1.2, TLSv1.3] # SSL configuration. The default is off. # List of root certificates for HTTPS server verifications @@ -1263,6 +1263,14 @@ logging.files: #metrics.period: 10s #state.period: 1m +# The `monitoring.cloud.id` setting overwrites the `monitoring.elasticsearch.hosts` +# setting. You can find the value for this setting in the Elastic Cloud web UI. +#monitoring.cloud.id: + +# The `monitoring.cloud.auth` setting overwrites the `monitoring.elasticsearch.username` +# and `monitoring.elasticsearch.password` settings. The format is `:`. +#monitoring.cloud.auth: + #================================ HTTP Endpoint ====================================== # Each beat can expose internal metrics through a HTTP endpoint. For security # reasons the endpoint is disabled by default. This feature is currently experimental.