Skip to content

Commit

Permalink
Add azure billing metricset (#19207) (#19860)
Browse files Browse the repository at this point in the history
* work on metricset

vendor

work

run

fix

change

fix

fix dependencies

work

fix

* remove vendor

* remove unused

* work on the billing

* make notice

* work on fields

* build dashboards

* make notice

* review

* make sure * is set to auto in gitattributes

* test

* update CLRF to LF

* update CLRF to LF

* notice

* notice

* Fix notice

* update visualization

Co-authored-by: Martijn Laarman <Mpdreamz@gmail.com>
Co-authored-by: Carlos Pérez-Aradros Herce <exekias@gmail.com>
(cherry picked from commit e69eb97)
  • Loading branch information
narph committed Jul 14, 2020
1 parent eeda621 commit a1e5965
Show file tree
Hide file tree
Showing 27 changed files with 1,697 additions and 4 deletions.
85 changes: 85 additions & 0 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13238,6 +13238,61 @@ 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 : github.com/shopspring/decimal
Version: v1.2.0
Licence type (autodetected): MIT
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/shopspring/decimal@v1.2.0/LICENSE:

The MIT License (MIT)

Copyright (c) 2015 Spring, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall 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.

- Based on https://github.com/oguzbilgic/fpd, which has the following license:
"""
The MIT License (MIT)

Copyright (c) 2013 Oguz Bilgic

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall 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.
"""


--------------------------------------------------------------------------------
Dependency : github.com/spf13/cobra
Version: v0.0.3
Expand Down Expand Up @@ -35364,6 +35419,36 @@ 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 : github.com/satori/go.uuid
Version: v1.2.0
Licence type (autodetected): MIT
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/satori/go.uuid@v1.2.0/LICENSE:

Copyright (C) 2013-2018 by Maxim Bublis <b@codemonkey.ru>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall 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.


--------------------------------------------------------------------------------
Dependency : github.com/sergi/go-diff
Version: v1.1.0
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ require (
github.com/samuel/go-parser v0.0.0-20130731160455-ca8abbf65d0e // indirect
github.com/samuel/go-thrift v0.0.0-20140522043831-2187045faa54
github.com/sanathkr/yaml v1.0.1-0.20170819201035-0056894fa522 // indirect
github.com/satori/go.uuid v1.2.0 // indirect
github.com/shirou/gopsutil v2.19.11+incompatible
github.com/shopspring/decimal v1.2.0
github.com/spf13/cobra v0.0.3
github.com/spf13/pflag v1.0.5
github.com/stretchr/objx v0.2.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -623,11 +623,15 @@ github.com/sanathkr/yaml v1.0.1-0.20170819201035-0056894fa522 h1:39BJIaZIhIBmXAT
github.com/sanathkr/yaml v1.0.1-0.20170819201035-0056894fa522/go.mod h1:tQTYKOQgxoH3v6dEmdHiz4JG+nbxWwM5fgPQUpSZqVQ=
github.com/santhosh-tekuri/jsonschema v1.2.4 h1:hNhW8e7t+H1vgY+1QeEQpveR6D4+OwKPXCfD2aieJis=
github.com/santhosh-tekuri/jsonschema v1.2.4/go.mod h1:TEAUOeZSmIxTTuHatJzrvARHiuO9LYd+cIxzgEHCQI4=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shirou/gopsutil v2.19.11+incompatible h1:lJHR0foqAjI4exXqWsU3DbH7bX1xvdhGdnXTIARA9W4=
github.com/shirou/gopsutil v2.19.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
Expand Down
117 changes: 117 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -4567,6 +4567,123 @@ type: object

--

[float]
=== billing

billing and usage details



*`azure.billing.currency`*::
+
--
The currency


type: keyword

--

*`azure.billing.pretax_cost`*::
+
--
Cost


type: float

--

*`azure.billing.department_name`*::
+
--
The department name


type: keyword

--

*`azure.billing.product`*::
+
--
The product type


type: keyword

--

*`azure.billing.usage_start`*::
+
--
The usage start date


type: date

--

*`azure.billing.usage_end`*::
+
--
The usage end date


type: date

--

*`azure.billing.billing_period_id`*::
+
--
The billing period id


type: keyword

--

*`azure.billing.account_name`*::
+
--
The billing account name


type: keyword

--

*`azure.billing.actual_cost`*::
+
--
The actual cost


type: float

--

*`azure.billing.forecast_cost`*::
+
--
The forecast cost


type: float

--

*`azure.billing.usage_date`*::
+
--
The usage date


type: date

--

*`azure.compute_vm.*.*`*::
+
--
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 24 additions & 1 deletion metricbeat/docs/modules/azure.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ The virtual machine scale sets dashboard is similar to the VM dashboard and show

image::./images/metricbeat-azure-vmss-overview.png[]

The Azure storage dashboards dashboards show all relevant metrics for the blob, file, table and queue storage services:
The Azure storage dashboards show all relevant metrics for the blob, file, table and queue storage services:

image::./images/metricbeat-azure-storage-overview.png[]

The Azure billing dashboards show relevant usage and forecast information:

image::./images/metricbeat-azure-billing-overview.png[]

[float]
=== Module-specific configuration notes

Expand Down Expand Up @@ -105,6 +109,11 @@ so the `period` for `container_service` metricset should be `300s` or multiples
This metricset will collect relevant metrics from specified database accounts, these metrics will have a timegrain every 5 minutes,
so the `period` for `database_account` metricset should be `300s` or multiples of `300s`.

[float]
=== `billing`
This metricset will collect relevant usage data and forecast information from a specific subscription, these metrics will have a timegrain every 24 hours,
so the `period` for `billing` metricset should be `24h` or multiples of `24h`.

[float]
=== `app_insights`
This metricset will collect application insights metrics, the `period` (interval) for the `app-insights` metricset is set by default at `300s`.
Expand Down Expand Up @@ -211,6 +220,16 @@ metricbeat.modules:
tenant_id: '${AZURE_TENANT_ID:""}'
subscription_id: '${AZURE_SUBSCRIPTION_ID:""}'
- module: azure
metricsets:
- billing
enabled: true
period: 24h
client_id: '${AZURE_CLIENT_ID:""}'
client_secret: '${AZURE_CLIENT_SECRET:""}'
tenant_id: '${AZURE_TENANT_ID:""}'
subscription_id: '${AZURE_SUBSCRIPTION_ID:""}'
- module: azure
metricsets:
- app_insights
Expand All @@ -228,6 +247,8 @@ The following metricsets are available:

* <<metricbeat-metricset-azure-app_insights,app_insights>>

* <<metricbeat-metricset-azure-billing,billing>>

* <<metricbeat-metricset-azure-compute_vm,compute_vm>>

* <<metricbeat-metricset-azure-compute_vm_scaleset,compute_vm_scaleset>>
Expand All @@ -246,6 +267,8 @@ The following metricsets are available:

include::azure/app_insights.asciidoc[]

include::azure/billing.asciidoc[]

include::azure/compute_vm.asciidoc[]

include::azure/compute_vm_scaleset.asciidoc[]
Expand Down
23 changes: 23 additions & 0 deletions metricbeat/docs/modules/azure/billing.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
////
This file is generated! See scripts/mage/docs_collector.go
////

[[metricbeat-metricset-azure-billing]]
=== Azure billing metricset

beta[]

include::../../../../x-pack/metricbeat/module/azure/billing/_meta/docs.asciidoc[]


==== Fields

For a description of each field in the metricset, see the
<<exported-fields-azure,exported fields>> section.

Here is an example document generated by this metricset:

[source,json]
----
include::../../../../x-pack/metricbeat/module/azure/billing/_meta/data.json[]
----
3 changes: 2 additions & 1 deletion metricbeat/docs/modules_list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ This file is generated! See scripts/mage/docs_collector.go
|<<metricbeat-metricset-aws-usage,usage>> beta[]
|<<metricbeat-metricset-aws-vpn,vpn>> beta[]
|<<metricbeat-module-azure,Azure>> |image:./images/icon-yes.png[Prebuilt dashboards are available] |
.9+| .9+| |<<metricbeat-metricset-azure-app_insights,app_insights>> beta[]
.10+| .10+| |<<metricbeat-metricset-azure-app_insights,app_insights>> beta[]
|<<metricbeat-metricset-azure-billing,billing>> beta[]
|<<metricbeat-metricset-azure-compute_vm,compute_vm>>
|<<metricbeat-metricset-azure-compute_vm_scaleset,compute_vm_scaleset>>
|<<metricbeat-metricset-azure-container_instance,container_instance>>
Expand Down
1 change: 1 addition & 0 deletions x-pack/metricbeat/include/list.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions x-pack/metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,16 @@ metricbeat.modules:
tenant_id: '${AZURE_TENANT_ID:""}'
subscription_id: '${AZURE_SUBSCRIPTION_ID:""}'

- module: azure
metricsets:
- billing
enabled: true
period: 24h
client_id: '${AZURE_CLIENT_ID:""}'
client_secret: '${AZURE_CLIENT_SECRET:""}'
tenant_id: '${AZURE_TENANT_ID:""}'
subscription_id: '${AZURE_SUBSCRIPTION_ID:""}'

- module: azure
metricsets:
- app_insights
Expand Down
10 changes: 10 additions & 0 deletions x-pack/metricbeat/module/azure/_meta/config.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@
tenant_id: '${AZURE_TENANT_ID:""}'
subscription_id: '${AZURE_SUBSCRIPTION_ID:""}'

- module: azure
metricsets:
- billing
enabled: true
period: 24h
client_id: '${AZURE_CLIENT_ID:""}'
client_secret: '${AZURE_CLIENT_SECRET:""}'
tenant_id: '${AZURE_TENANT_ID:""}'
subscription_id: '${AZURE_SUBSCRIPTION_ID:""}'

- module: azure
metricsets:
- app_insights
Expand Down
Loading

0 comments on commit a1e5965

Please sign in to comment.