Initial import of the LMA collector plugin
This is an import of the initial LMA PoC code. For now, it only covers the collection of logs (notifications will be added in a subsequent commit). There's been a bit of rewrite to: - decouple the Heka configuration from the LMA collector. - run the Heka service as non-root when possible (Ubuntu only for now due to file permission issues on CentOS [1]). - adapt to version 0.9 of Heka. [1] https://bugs.launchpad.net/fuel/+bug/1425954 Change-Id: I4472b49a25e18e06984b5b29bdce18f917137bc8
This commit is contained in:
parent
6854302bd6
commit
c9ee4d30d9
|
@ -0,0 +1,202 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
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:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) 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
|
||||
|
||||
(d) 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
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
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.
|
||||
|
|
@ -0,0 +1,202 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
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:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) 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
|
||||
|
||||
(d) 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
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
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.
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
Heka module for Puppet
|
||||
======================
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
Puppet module for configuring Heka.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
To deploy the Heka service on a host.
|
||||
|
||||
```puppet
|
||||
# Configure the base heka service
|
||||
class {'heka':
|
||||
}
|
||||
```
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
This module supports only Fuel-based deployments using Neutron.
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Licensed under the terms of the Apache License, version 2.0.
|
||||
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
None
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Licensed under the terms of the Apache License, version 2.0.
|
||||
|
||||
Contact
|
||||
-------
|
||||
|
||||
Simon Pasquier, <spasquier@mirantis.com>
|
||||
|
||||
Support
|
||||
-------
|
||||
|
||||
See the Contact section.
|
|
@ -0,0 +1,20 @@
|
|||
define heka::decoder::sandbox (
|
||||
$ensure = present,
|
||||
$config_dir,
|
||||
$filename,
|
||||
$config = {},
|
||||
) {
|
||||
|
||||
include heka::params
|
||||
|
||||
validate_hash($config)
|
||||
|
||||
file { "${config_dir}/decoder-${title}.toml":
|
||||
ensure => $ensure,
|
||||
content => template('heka/decoder/sandbox.toml.erb'),
|
||||
mode => '0600',
|
||||
owner => $heka::params::user,
|
||||
group => $heka::params::user,
|
||||
require => File[$config_dir],
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
define heka::encoder::es_json (
|
||||
$ensure = present,
|
||||
$config_dir,
|
||||
$es_index_from_timestamp = false,
|
||||
$index = undef,
|
||||
) {
|
||||
|
||||
include heka::params
|
||||
|
||||
file { "${config_dir}/encoder-${title}.toml":
|
||||
ensure => $ensure,
|
||||
content => template('heka/encoder/es_json.toml.erb'),
|
||||
mode => '0600',
|
||||
owner => $heka::params::user,
|
||||
group => $heka::params::user,
|
||||
require => File[$config_dir],
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
define heka::filter::sandbox (
|
||||
$ensure = present,
|
||||
$config_dir,
|
||||
$filename,
|
||||
$preserve_data = false,
|
||||
$message_matcher = 'FALSE',
|
||||
$ticker_interval = undef,
|
||||
$config = {},
|
||||
) {
|
||||
|
||||
include heka::params
|
||||
|
||||
validate_hash($config)
|
||||
|
||||
file { "${config_dir}/filter-${title}.toml":
|
||||
ensure => $ensure,
|
||||
content => template('heka/filter/sandbox.toml.erb'),
|
||||
mode => '0600',
|
||||
owner => $heka::params::user,
|
||||
group => $heka::params::user,
|
||||
require => File[$config_dir],
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
# == Class: heka
|
||||
#
|
||||
# Install and configure the core of the Heka service.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*service_name*]
|
||||
# The name of the service daemon (default: 'hekad').
|
||||
#
|
||||
# [*config_dir*]
|
||||
# The directory where to store the configuration (default: '/etc/hekad').
|
||||
#
|
||||
# [*run_as_root*]
|
||||
# Whether or not to run the Heka service as root (default: false).
|
||||
# You may have to set this parameter to true on some systems to access log
|
||||
# files, run additional commands, ...
|
||||
#
|
||||
# [*additional_groups*]
|
||||
# Additional groups to which the heka user should be added.
|
||||
#
|
||||
# [*hostname*]
|
||||
# Hostname reported by the service in the messages (default: the host's FQDN).
|
||||
#
|
||||
# [*maxprocs*]
|
||||
# The number of CPU cores (default: $processorcount).
|
||||
#
|
||||
# [*dashboard_address*]
|
||||
# The listening adddress for the Heka dashboard (default: undef).
|
||||
#
|
||||
# [*dashboard_port*]
|
||||
# The listening port for the Heka dashboard (default: 4352).
|
||||
#
|
||||
# === Examples
|
||||
#
|
||||
# class { 'heka':
|
||||
# hostname => 'foobar'
|
||||
# dashboard_address => '127.0.0.1',
|
||||
# }
|
||||
#
|
||||
# === Authors
|
||||
#
|
||||
# Simon Pasquier <spasquier@mirantis.com>
|
||||
#
|
||||
# === Copyright
|
||||
#
|
||||
# Copyright 2015 Mirantis Inc, unless otherwise noted.
|
||||
#
|
||||
class heka (
|
||||
$service_name = $heka::params::service_name,
|
||||
$config_dir = $heka::params::config_dir,
|
||||
$run_as_root = $heka::params::run_as_root,
|
||||
$additional_groups = $heka::params::additional_groups,
|
||||
$hostname = $heka::params::hostname,
|
||||
$maxprocs = $heka::params::maxprocs,
|
||||
$dashboard_address = $heka::params::dashboard_address,
|
||||
$dashboard_port = $heka::params::dashboard_port,
|
||||
) inherits heka::params {
|
||||
|
||||
$heka_user = $heka::params::user
|
||||
$base_dir = "/var/cache/${service_name}"
|
||||
$log_file = "/var/log/${service_name}.log"
|
||||
|
||||
package { $heka::params::package_name:
|
||||
ensure => present,
|
||||
alias => 'heka',
|
||||
}
|
||||
|
||||
file { $heka::params::lua_modules_dir:
|
||||
ensure => directory,
|
||||
require => Package['heka'],
|
||||
}
|
||||
|
||||
user { $heka_user:
|
||||
shell => "/sbin/nologin",
|
||||
home => $base_dir,
|
||||
system => true,
|
||||
groups => $additional_groups,
|
||||
alias => 'heka',
|
||||
}
|
||||
|
||||
file { $base_dir:
|
||||
ensure => directory,
|
||||
owner => $heka_user,
|
||||
group => $heka_user,
|
||||
mode => '0750',
|
||||
require => [User['heka'], Package['heka']],
|
||||
}
|
||||
|
||||
file { $config_dir:
|
||||
ensure => directory,
|
||||
owner => $heka_user,
|
||||
group => $heka_user,
|
||||
mode => '0750',
|
||||
require => [User['heka'], Package['heka']],
|
||||
}
|
||||
|
||||
file { $log_file:
|
||||
ensure => present,
|
||||
owner => $heka_user,
|
||||
group => $heka_user,
|
||||
mode => '0660',
|
||||
require => [User['heka'], Package['heka']],
|
||||
}
|
||||
|
||||
file { "/etc/logrotate.d/${service_name}":
|
||||
ensure => present,
|
||||
content => template('heka/logrotate.conf.erb'),
|
||||
}
|
||||
|
||||
case $::osfamily {
|
||||
'Debian': {
|
||||
file {"/etc/init/${service_name}.conf":
|
||||
ensure => present,
|
||||
content => template('heka/hekad.upstart.conf.erb'),
|
||||
notify => Service[$service_name],
|
||||
alias => 'heka_init_script',
|
||||
}
|
||||
}
|
||||
|
||||
'RedHat': {
|
||||
file { "/etc/init.d/${service_name}":
|
||||
ensure => present,
|
||||
content => template('heka/hekad.initd.erb'),
|
||||
mode => '0755',
|
||||
notify => Service[$service_name],
|
||||
alias => 'heka_init_script',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
file { "${config_dir}/global.toml":
|
||||
ensure => present,
|
||||
content => template('heka/global.toml.erb'),
|
||||
mode => '0600',
|
||||
owner => $heka_user,
|
||||
group => $heka_user,
|
||||
require => File[$config_dir],
|
||||
notify => Service[$service_name],
|
||||
}
|
||||
|
||||
if $dashboard_address {
|
||||
file { "${config_dir}/dashboard.toml":
|
||||
ensure => present,
|
||||
content => template('heka/output/dashboard.toml.erb'),
|
||||
mode => '0600',
|
||||
owner => $heka_user,
|
||||
group => $heka_user,
|
||||
require => File[$config_dir],
|
||||
notify => Service[$service_name],
|
||||
}
|
||||
}
|
||||
|
||||
service { $service_name:
|
||||
enable => 'true',
|
||||
ensure => 'running',
|
||||
require => [File['heka_init_script'], File[$config_dir], File[$base_dir], File[$log_file]],
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
define heka::input::logstreamer(
|
||||
$ensure = present,
|
||||
$config_dir,
|
||||
$decoder,
|
||||
$splitter = undef,
|
||||
$log_directory = '/var/log',
|
||||
$file_match = undef,
|
||||
$differentiator = undef,
|
||||
) {
|
||||
|
||||
include heka::params
|
||||
|
||||
file { "${config_dir}/logstreamer-${title}.toml":
|
||||
ensure => $ensure,
|
||||
content => template('heka/input/logstreamer.toml.erb'),
|
||||
mode => '0600',
|
||||
owner => $heka::params::user,
|
||||
group => $heka::params::user,
|
||||
require => File[$config_dir],
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
define heka::output::elasticsearch (
|
||||
$ensure = present,
|
||||
$config_dir,
|
||||
$server = undef,
|
||||
$port = undef,
|
||||
$encoder = $title,
|
||||
$message_matcher = 'FALSE',
|
||||
$flush_interval = 5,
|
||||
$flush_count = 10,
|
||||
$use_buffering = true,
|
||||
$queue_max_buffer_size = 1000000000, # 1GB
|
||||
$queue_full_action = 'drop'
|
||||
) {
|
||||
|
||||
include heka::params
|
||||
|
||||
file { "${config_dir}/output-${title}.toml":
|
||||
ensure => $ensure,
|
||||
content => template('heka/output/elasticsearch.toml.erb'),
|
||||
mode => '0600',
|
||||
owner => $heka::params::user,
|
||||
group => $heka::params::user,
|
||||
require => File[$config_dir],
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
class heka::params {
|
||||
$package_name = 'heka'
|
||||
$service_name = 'hekad'
|
||||
$user = 'heka'
|
||||
$run_as_root = false
|
||||
$additional_groups = []
|
||||
|
||||
$hostname = undef
|
||||
$maxprocs = $::processorcount
|
||||
$dashboard_address = undef
|
||||
$dashboard_port = '4352'
|
||||
|
||||
$config_dir = "/etc/${service_name}"
|
||||
$share_dir = "/usr/share/heka"
|
||||
$lua_modules_dir = "/usr/share/heka/lua_modules"
|
||||
|
||||
# required to read the log files
|
||||
case $::osfamily {
|
||||
'Debian': {
|
||||
$groups = ['syslog', 'adm']
|
||||
}
|
||||
'RedHat': {
|
||||
$groups = ['adm']
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
define heka::splitter::regex (
|
||||
$ensure = present,
|
||||
$config_dir,
|
||||
$delimiter,
|
||||
$delimiter_eol = undef
|
||||
) {
|
||||
|
||||
include heka::params
|
||||
|
||||
file { "${config_dir}/splitter-${title}.toml":
|
||||
ensure => $ensure,
|
||||
content => template('heka/splitter/regex.toml.erb'),
|
||||
mode => '0600',
|
||||
owner => $heka::params::user,
|
||||
group => $heka::params::user,
|
||||
require => File[$config_dir],
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
define heka::splitter::token (
|
||||
$ensure = present,
|
||||
$config_dir,
|
||||
$delimiter,
|
||||
) {
|
||||
|
||||
include heka::params
|
||||
|
||||
file { "${config_dir}/splitter-${title}.toml":
|
||||
ensure => $ensure,
|
||||
content => template('heka/splitter/token.toml.erb'),
|
||||
mode => '0600',
|
||||
owner => $heka::params::user,
|
||||
group => $heka::params::user,
|
||||
require => File[$config_dir],
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"name": "heka",
|
||||
"version": "1.0.0",
|
||||
"author": "Simon Pasquier <spasquier@mirantis.com>",
|
||||
"summary": "Puppet Heka Module",
|
||||
"license": "Apache License 2.0",
|
||||
"source": "git://git.openstack.org/cgit/stackforge/fuel-plugin-lma-collector.git",
|
||||
"project_page": "none",
|
||||
"issues_url": "none",
|
||||
"operatingsystem_support": [
|
||||
{
|
||||
"operatingsystem": "Ubuntu",
|
||||
"operatingsystemrelease": ["12.04", "14.04"]
|
||||
},
|
||||
{
|
||||
"operatingsystem": "CentOS",
|
||||
"operatingsystemrelease": ["6"]
|
||||
}
|
||||
],
|
||||
"description": "Puppet module for configuring Heka",
|
||||
"dependencies": [
|
||||
{"name": "puppetlabs/stdlib", "version_requirement": "4.x"}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
dir = File.expand_path(File.dirname(__FILE__))
|
||||
$LOAD_PATH.unshift File.join(dir, 'lib')
|
||||
|
||||
require 'mocha'
|
||||
require 'puppet'
|
||||
require 'rspec'
|
||||
require 'spec/autorun'
|
||||
|
||||
Spec::Runner.configure do |config|
|
||||
config.mock_with :mocha
|
||||
end
|
||||
|
||||
# We need this because the RAL uses 'should' as a method. This
|
||||
# allows us the same behaviour but with a different method name.
|
||||
class Object
|
||||
alias :must :should
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
[<%= @title %>_decoder]
|
||||
type = "SandboxDecoder"
|
||||
filename = "<%= @filename %>"
|
||||
|
||||
<% if @config.size() > 0 %>
|
||||
[<%= @title %>_decoder.config]
|
||||
<% @config.each do |k,v| %>
|
||||
<%= k %> = '<%= v %>'
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -0,0 +1,4 @@
|
|||
[<%= @title %>_encoder]
|
||||
type = "ESJsonEncoder"
|
||||
index = "<%= @index %>"
|
||||
es_index_from_timestamp = <%= @es_index_from_timestamp %>
|
|
@ -0,0 +1,15 @@
|
|||
[<%= @title %>_filter]
|
||||
type = "SandboxFilter"
|
||||
filename = "<%= @filename %>"
|
||||
preserve_data = <%= @preserve_data %>
|
||||
message_matcher = "<%= @message_matcher %>"
|
||||
<% if @ticker_interval %>
|
||||
ticker_interval = <%= @ticker_interval %>
|
||||
<% end %>
|
||||
|
||||
<% if @config.size() > 0 %>
|
||||
[<%= @title %>_filter.config]
|
||||
<% @config.each do |k,v| %>
|
||||
<%= @k %> = '<%= @v %>'
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -0,0 +1,6 @@
|
|||
[hekad]
|
||||
maxprocs=<%= @maxprocs %>
|
||||
base_dir="<%= @base_dir %>"
|
||||
<% if @hostname %>
|
||||
hostname="<%= @hostname %>"
|
||||
<% end %>
|
|
@ -0,0 +1,104 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# hekad <%= @service_name %>
|
||||
#
|
||||
# chkconfig: - 98 02
|
||||
# description: Starts and stops a single heka instance on this system
|
||||
### END INIT INFO
|
||||
|
||||
#
|
||||
# Source function library.
|
||||
#
|
||||
if [ -f /etc/rc.d/init.d/functions ]; then
|
||||
. /etc/rc.d/init.d/functions
|
||||
fi
|
||||
|
||||
exec="/usr/bin/hekad"
|
||||
prog="<%= @service_name %>"
|
||||
pidfile=/var/run/${prog}.pid
|
||||
|
||||
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
|
||||
|
||||
lockfile=/var/lock/subsys/$prog
|
||||
|
||||
HEKA_USER=root
|
||||
|
||||
start() {
|
||||
[ -x $exec ] || exit 5
|
||||
[ -f $CONF_FILE ] || exit 6
|
||||
<% unless @run_as_root -%>
|
||||
touch <%= @log_file %>
|
||||
chown <%= @heka_user %>:<%= @heka_user %> <%= @log_file %>
|
||||
<% end -%>
|
||||
echo -n $"Starting $prog: "
|
||||
daemonize -p $pidfile -e <%= @log_file %> <%= @run_as_root ? "" : "-u #{ @heka_user }" %> -l $lockfile $exec -config=<%= @config_dir %>
|
||||
retval=$?
|
||||
[ $retval -eq 0 ] && success || failure
|
||||
echo
|
||||
[ $retval -eq 0 ] && touch $lockfile
|
||||
return $retval
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n $"Stopping $prog: "
|
||||
killproc -p $pidfile $prog
|
||||
retval=$?
|
||||
echo
|
||||
[ $retval -eq 0 ] && rm -f $lockfile
|
||||
return $retval
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
reload() {
|
||||
restart
|
||||
}
|
||||
|
||||
force_reload() {
|
||||
restart
|
||||
}
|
||||
|
||||
rh_status() {
|
||||
# run checks to determine if the service is running or use generic status
|
||||
status -p $pidfile $prog
|
||||
}
|
||||
|
||||
rh_status_q() {
|
||||
rh_status >/dev/null 2>&1
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
rh_status_q && exit 0
|
||||
$1
|
||||
;;
|
||||
stop)
|
||||
rh_status_q || exit 0
|
||||
$1
|
||||
;;
|
||||
restart)
|
||||
$1
|
||||
;;
|
||||
reload)
|
||||
rh_status_q || exit 7
|
||||
$1
|
||||
;;
|
||||
force-reload)
|
||||
force_reload
|
||||
;;
|
||||
status)
|
||||
rh_status
|
||||
;;
|
||||
condrestart|try-restart)
|
||||
rh_status_q || exit 0
|
||||
restart
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
|
||||
exit 2
|
||||
esac
|
||||
exit $?
|
|
@ -0,0 +1,17 @@
|
|||
# <%= @service_name %>
|
||||
|
||||
description "<%= @service_name %>"
|
||||
|
||||
start on runlevel [2345]
|
||||
stop on runlevel [!2345]
|
||||
|
||||
respawn
|
||||
|
||||
<% unless @run_as_root -%>
|
||||
pre-start script
|
||||
touch <%= @log_file %>
|
||||
chown <%= @heka_user %>:<%= @heka_user %> <%= @log_file %>
|
||||
end script
|
||||
<% end -%>
|
||||
|
||||
exec <%= @run_as_root ? "" : "sudo -u #{ @heka_user }" %> /usr/bin/hekad -config=<%= @config_dir %> 2>><%= @log_file %>
|
|
@ -0,0 +1,9 @@
|
|||
[<%= @title %>_logstreamer]
|
||||
type = "LogstreamerInput"
|
||||
log_directory = "<%= @log_directory %>"
|
||||
file_match = '<%= @file_match %>'
|
||||
<% if @differentiator -%>
|
||||
differentiator = <%= @differentiator %>
|
||||
<% end -%>
|
||||
decoder = "<%= @decoder %>_decoder"
|
||||
splitter = "<%= @splitter ? "#{ @splitter }_splitter" : "TokenSplitter" %>"
|
|
@ -0,0 +1,4 @@
|
|||
<%= @log_file %> {
|
||||
daily
|
||||
missingok
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
[DashboardOutput]
|
||||
address = "<%= @dashboard_address %>:<%= @dashboard_port %>"
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
[<%= @title %>_output]
|
||||
type = "ElasticSearchOutput"
|
||||
message_matcher = "<%= @message_matcher %>"
|
||||
encoder = "<%= @encoder %>_encoder"
|
||||
|
||||
<% # Heka expects milliseconds here -%>
|
||||
flush_interval = <%= @flush_interval.to_i() * 1000 %>
|
||||
flush_count = <%= @flush_count %>
|
||||
|
||||
server = "http://<%= @server %>:<%= @port %>"
|
||||
|
||||
use_buffering = <%= @use_buffering %>
|
||||
queue_max_buffer_size = <%= @queue_max_buffer_size %>
|
||||
queue_full_action = "<%= @queue_full_action %>"
|
|
@ -0,0 +1,6 @@
|
|||
[<%= @title %>_splitter]
|
||||
type = "RegexSplitter"
|
||||
delimiter = '<%= @delimiter %>'
|
||||
<% unless @delimiter_eol.nil? -%>
|
||||
delimiter_eol = <%= @delimiter_eol %>
|
||||
<% end -%>
|
|
@ -0,0 +1,3 @@
|
|||
[<%= @title %>_splitter]
|
||||
type = "TokenSplitter"
|
||||
delimiter = "<%= @delimiter %>"
|
|
@ -0,0 +1,12 @@
|
|||
# The baseline for module testing used by Puppet Labs is that each manifest
|
||||
# should have a corresponding test manifest that declares that class or defined
|
||||
# type.
|
||||
#
|
||||
# Tests are then run by using puppet apply --noop (to check for compilation
|
||||
# errors and view a log of events) or by fully applying the test in a virtual
|
||||
# environment (to compare the resulting system state to the desired state).
|
||||
#
|
||||
# Learn more about module testing here:
|
||||
# http://docs.puppetlabs.com/guides/tests_smoke.html
|
||||
#
|
||||
include heka
|
|
@ -0,0 +1,202 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
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:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) 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
|
||||
|
||||
(d) 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
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
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.
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
LMA collector module for Puppet
|
||||
===============================
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
Puppet module for configuring the Logging, Monitoring and Alerting collector.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
To deploy the LMA collector service on a host and forward collected data to
|
||||
ElasticSearch and/or InfluxDB servers.
|
||||
|
||||
```puppet
|
||||
# Configure the common components of the collector service
|
||||
class {'lma_collector':
|
||||
tags => {
|
||||
tag_A => 'some value'
|
||||
}
|
||||
}
|
||||
|
||||
# Collect system logs
|
||||
class { 'lma_collector::system_logs':
|
||||
}
|
||||
|
||||
# Send data to ElasticSearch
|
||||
class { 'lma_collector::elasticsearch':
|
||||
server => '10.20.0.2'
|
||||
}
|
||||
```
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
This module supports only Fuel-based deployments using Neutron.
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Licensed under the terms of the Apache License, version 2.0.
|
||||
|
||||
Contact
|
||||
-------
|
||||
|
||||
Simon Pasquier, <spasquier@mirantis.com>
|
||||
|
||||
Support
|
||||
-------
|
||||
|
||||
See the Contact section.
|
|
@ -0,0 +1,135 @@
|
|||
-- Copyright 2015 Mirantis, Inc.
|
||||
--
|
||||
-- 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.
|
||||
local string = require 'string'
|
||||
local extra = require 'extra_fields'
|
||||
local patt = require 'patterns'
|
||||
local pairs = pairs
|
||||
|
||||
local M = {}
|
||||
setfenv(1, M) -- Remove external access to contain everything in the module
|
||||
|
||||
severity_to_label_map = {
|
||||
[0] = 'EMERGENCY',
|
||||
[1] = 'ALERT',
|
||||
[2] = 'CRITICAL',
|
||||
[3] = 'ERROR',
|
||||
[4] = 'WARNING',
|
||||
[5] = 'NOTICE',
|
||||
[6] = 'INFO',
|
||||
[7] = 'DEBUG',
|
||||
}
|
||||
|
||||
label_to_severity_map = {
|
||||
EMERGENCY = 0,
|
||||
ALERT = 1,
|
||||
CRITICAL = 2,
|
||||
ERROR = 3,
|
||||
WARNING = 4,
|
||||
NOTICE = 5,
|
||||
INFO= 6,
|
||||
DEBUG = 7,
|
||||
}
|
||||
|
||||
metric_type = {
|
||||
COUNTER = "counter",
|
||||
GAUGE = "gauge",
|
||||
DERIVE = "derive",
|
||||
}
|
||||
|
||||
-- Parse a Syslog-based payload and update the Heka message
|
||||
-- Return true if successful, false otherwise
|
||||
function parse_syslog_message(grammar, payload, msg)
|
||||
-- capture everything after the first backslash because syslog_grammar will
|
||||
-- drop it
|
||||
local extra_msg = string.match(payload, '^[^\n]+\n(.+)\n$')
|
||||
|
||||
local fields = grammar:match(payload)
|
||||
if not fields then
|
||||
return false
|
||||
end
|
||||
|
||||
msg.Timestamp = fields.timestamp
|
||||
fields.timestamp = nil
|
||||
|
||||
msg.Hostname = fields.hostname
|
||||
fields.hostname = nil
|
||||
|
||||
msg.Pid = fields.syslogtag.pid or 0
|
||||
fields.programname = fields.syslogtag.programname
|
||||
fields.syslogtag = nil
|
||||
|
||||
if fields.pri then
|
||||
msg.Severity = fields.pri.severity
|
||||
fields.syslogfacility = fields.pri.facility
|
||||
fields.pri = nil
|
||||
else
|
||||
msg.Severity = fields.syslogseverity or fields["syslogseverity-text"]
|
||||
or fields.syslogpriority or fields["syslogpriority-text"]
|
||||
fields.syslogseverity = nil
|
||||
fields["syslogseverity-text"] = nil
|
||||
fields.syslogpriority = nil
|
||||
fields["syslogpriority-text"] = nil
|
||||
end
|
||||
fields.severity_label = severity_to_label_map[msg.Severity]
|
||||
|
||||
if extra_msg ~= nil then
|
||||
msg.Payload = fields.msg .. "\n" .. extra_msg
|
||||
else
|
||||
msg.Payload = fields.msg
|
||||
end
|
||||
fields.msg = nil
|
||||
|
||||
msg.Fields = fields
|
||||
|
||||
inject_tags(msg)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- Inject tags into the Heka message
|
||||
function inject_tags(msg)
|
||||
for k,v in pairs(extra.tags) do
|
||||
if msg.Fields[k] == nil then
|
||||
msg.Fields[k] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Convert a datetime string to the RFC3339 format
|
||||
-- it supports a variety of datetime formats.
|
||||
-- Return the string unmodified if the datetime couldn't be parsed
|
||||
function format_datetime (raw_datetime)
|
||||
local datetime
|
||||
local t = patt.TimestampTable:match(raw_datetime)
|
||||
if t then
|
||||
local frac = 0
|
||||
local offset_sign = '+'
|
||||
local offset_hour = 0
|
||||
local offset_min = 0
|
||||
if t.sec_frac then frac = t.sec_frac end
|
||||
if t.offset_sign then offset_sign = t.offset_sign end
|
||||
if t.offset_hour then offset_hour = t.offset_hour end
|
||||
if t.offset_min then offset_min = t.offset_min end
|
||||
datetime = string.format("%04d-%02d-%02dT%02d:%02d:%02d.%06d%s%02d:%02d",
|
||||
t.year, t.month, t.day, t.hour, t.min, t.sec, frac*1e6, offset_sign,
|
||||
offset_hour, offset_min)
|
||||
end
|
||||
return datetime
|
||||
end
|
||||
|
||||
function chomp(s)
|
||||
return string.gsub(s, "\n$", "")
|
||||
end
|
||||
|
||||
return M
|
|
@ -0,0 +1,61 @@
|
|||
-- Copyright 2015 Mirantis, Inc.
|
||||
--
|
||||
-- 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.
|
||||
local table = require 'table'
|
||||
local dt = require "date_time"
|
||||
local l = require 'lpeg'
|
||||
l.locale(l)
|
||||
|
||||
local M = {}
|
||||
setfenv(1, M) -- Remove external access to contain everything in the module
|
||||
|
||||
function format_uuid(t)
|
||||
return table.concat(t, '-')
|
||||
end
|
||||
|
||||
sp = l.space
|
||||
colon = l.P":"
|
||||
dash = l.P"-"
|
||||
|
||||
local x4digit = l.xdigit * l.xdigit * l.xdigit * l.xdigit
|
||||
local uuid_dash = l.C(x4digit * x4digit * dash * x4digit * dash * x4digit * dash * x4digit * dash * x4digit * x4digit * x4digit)
|
||||
local uuid_nodash = l.Ct(l.C(x4digit * x4digit) * l.C(x4digit) * l.C(x4digit) * l.C(x4digit) * l.C(x4digit * x4digit * x4digit)) / format_uuid
|
||||
|
||||
-- Return a UUID string in canonical format (eg with dashes)
|
||||
Uuid = uuid_nodash + uuid_dash
|
||||
|
||||
-- Parse a datetime string and return a table with the following keys
|
||||
-- year (string)
|
||||
-- month (string)
|
||||
-- day (string)
|
||||
-- hour (string)
|
||||
-- min (string)
|
||||
-- sec (string)
|
||||
-- sec_frac (number less than 1, can be nil)
|
||||
-- offset_sign ('-' or '+', can be nil)
|
||||
-- offset_hour (number, can be nil)
|
||||
-- offset_min (number, can be nil)
|
||||
--
|
||||
-- The datetime string can be formatted as
|
||||
-- 'YYYY-MM-DD( |T)HH:MM:SS(.ssssss)?(offset indicator)?'
|
||||
TimestampTable = l.Ct(dt.rfc3339_full_date * (sp + l.P"T") * dt.rfc3339_partial_time * dt.rfc3339_time_offset^-1)
|
||||
|
||||
-- Returns the parsed datetime converted to nanosec
|
||||
Timestamp = TimestampTable / dt.time_to_ns
|
||||
|
||||
programname = (l.R("az", "AZ", "09") + l.P"." + dash + l.P"_")^1
|
||||
Pid = l.digit^1
|
||||
SeverityLabel = l.P"CRITICAL" + l.P"ERROR" + l.P"WARNING" + l.P"INFO" + l.P"AUDIT" + l.P"DEBUG"
|
||||
Message = l.P(1)^0
|
||||
|
||||
return M
|
|
@ -0,0 +1,40 @@
|
|||
-- Copyright 2015 Mirantis, Inc.
|
||||
--
|
||||
-- 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.
|
||||
local syslog = require "syslog"
|
||||
local utils = require 'lma_utils'
|
||||
|
||||
local msg = {
|
||||
Timestamp = nil,
|
||||
Type = 'log',
|
||||
Hostname = nil,
|
||||
Payload = nil,
|
||||
Pid = nil,
|
||||
Fields = nil,
|
||||
Severity = nil,
|
||||
}
|
||||
|
||||
local syslog_pattern = read_config("syslog_pattern") or error("syslog_pattern configuration must be specified")
|
||||
|
||||
local syslog_grammar = syslog.build_rsyslog_grammar(syslog_pattern)
|
||||
|
||||
function process_message ()
|
||||
local log = read_message("Payload")
|
||||
|
||||
if utils.parse_syslog_message(syslog_grammar, log, msg) then
|
||||
inject_message(msg)
|
||||
return 0
|
||||
end
|
||||
|
||||
return -1
|
||||
end
|
|
@ -0,0 +1,58 @@
|
|||
-- Copyright 2015 Mirantis, Inc.
|
||||
--
|
||||
-- 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.
|
||||
require "string"
|
||||
local l = require 'lpeg'
|
||||
l.locale(l)
|
||||
|
||||
local syslog = require "syslog"
|
||||
local patt = require 'patterns'
|
||||
local utils = require 'lma_utils'
|
||||
|
||||
local msg = {
|
||||
Timestamp = nil,
|
||||
Type = 'log',
|
||||
Hostname = nil,
|
||||
Payload = nil,
|
||||
Pid = nil,
|
||||
Fields = nil,
|
||||
Severity = nil,
|
||||
}
|
||||
|
||||
local syslog_pattern = read_config("syslog_pattern") or error("syslog_pattern configuration must be specified")
|
||||
|
||||
local sp = l.space
|
||||
local colon = l.P":"
|
||||
|
||||
local syslog_grammar = syslog.build_rsyslog_grammar(syslog_pattern)
|
||||
|
||||
-- mysqld logs are cranky,the date is YYMMMDD, the hours have no leading zero and the "real" severity level is enclosed by square brackets...
|
||||
local mysql_grammar = l.Ct(l.digit^-6 * sp^1 * l.digit^-2 * colon * l.digit^-2 * colon * l.digit^-2 * sp^1 * l.P"[" * l.Cg(l.R("az", "AZ")^0 / string.upper, "SeverityLabel") * l.P"]" * sp^1 * l.Cg(patt.Message, "Message"))
|
||||
|
||||
|
||||
function process_message ()
|
||||
local log = read_message("Payload")
|
||||
|
||||
if not utils.parse_syslog_message(syslog_grammar, log, msg) then
|
||||
return -1
|
||||
end
|
||||
|
||||
local m = mysql_grammar:match(msg.Payload)
|
||||
if m then
|
||||
msg.Fields.severity_label = m.SeverityLabel
|
||||
msg.Payload = m.Message
|
||||
end
|
||||
|
||||
inject_message(msg)
|
||||
return 0
|
||||
end
|
|
@ -0,0 +1,126 @@
|
|||
-- Copyright 2015 Mirantis, Inc.
|
||||
--
|
||||
-- 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.
|
||||
require "string"
|
||||
require "cjson"
|
||||
|
||||
local patt = require 'patterns'
|
||||
local utils = require 'lma_utils'
|
||||
|
||||
local msg = {
|
||||
Timestamp = nil,
|
||||
Type = "notification",
|
||||
Payload = nil,
|
||||
Fields = nil
|
||||
}
|
||||
|
||||
-- Mapping table between the attributes in the notification's payload and the
|
||||
-- fields in the Heka message
|
||||
local payload_fields = {
|
||||
-- all
|
||||
tenant_id = 'tenant_id',
|
||||
user_id = 'user_id',
|
||||
display_name = 'display_name',
|
||||
-- nova
|
||||
vcpus = 'vcpus',
|
||||
availability_zone = 'availability_zone',
|
||||
instance_id = 'instance_id',
|
||||
instance_type = 'instance_type',
|
||||
image_name = 'image_name',
|
||||
memory_mb = 'memory_mb',
|
||||
disk_gb = 'disk_gb',
|
||||
state = 'state',
|
||||
old_state = 'old_state',
|
||||
old_task_state = 'old_task_state',
|
||||
new_task_state = 'new_task_state',
|
||||
created_at = 'created_at',
|
||||
launched_at = 'launched_at',
|
||||
deleted_at = 'deleted_at',
|
||||
terminated_at = 'terminated_at',
|
||||
-- neutron
|
||||
network_id = 'network_id',
|
||||
subnet_id = 'subnet_id',
|
||||
port_id = 'port_id',
|
||||
-- cinder
|
||||
volume_id = 'volume_id',
|
||||
size = 'size',
|
||||
status = 'state',
|
||||
replication_status = 'replication_status',
|
||||
}
|
||||
|
||||
function normalize_uuid(uuid)
|
||||
return patt.Uuid:match(uuid)
|
||||
end
|
||||
|
||||
-- Mapping table defining transformation functions to be applied, keys are the
|
||||
-- attributes in the notification's payload and values are Lua functions
|
||||
local transform_functions = {
|
||||
created_at = utils.format_datetime,
|
||||
launched_at = utils.format_datetime,
|
||||
deleted_at = utils.format_datetime,
|
||||
terminated_at = utils.format_datetime,
|
||||
user_id = normalize_uuid,
|
||||
tenant_id = normalize_uuid,
|
||||
instance_id = normalize_uuid,
|
||||
network_id = normalize_uuid,
|
||||
subnet_id = normalize_uuid,
|
||||
port_id = normalize_uuid,
|
||||
volume_id = normalize_uuid,
|
||||
}
|
||||
|
||||
local service = read_config("service") or error("'service' configuration must be specified")
|
||||
local include_full_notification = read_config("include_full_notification") or false
|
||||
|
||||
function process_message ()
|
||||
local data = read_message("Payload")
|
||||
local ok, notif = pcall(cjson.decode, data)
|
||||
if not ok then
|
||||
return -1
|
||||
end
|
||||
|
||||
if include_full_notification then
|
||||
msg.Payload = data
|
||||
else
|
||||
msg.Payload = cjson.encode(notif.payload)
|
||||
end
|
||||
|
||||
msg.Fields = {}
|
||||
msg.Logger = service
|
||||
msg.Severity = utils.label_to_severity_map[notif.priority]
|
||||
msg.Timestamp = patt.Timestamp:match(notif.timestamp)
|
||||
msg.Fields.publisher, msg.Hostname = string.match(notif.publisher_id, '([^.]+)%.([%w_-]+)')
|
||||
if notif.payload.host ~= nil then
|
||||
msg.Hostname = string.match(notif.payload.host, '([%w_-]+)')
|
||||
end
|
||||
|
||||
msg.Fields.event_type = notif.event_type
|
||||
msg.Fields.severity_label = notif.priority
|
||||
msg.Fields.hostname = msg.Hostname
|
||||
|
||||
for k, v in pairs(payload_fields) do
|
||||
local val = notif.payload[k]
|
||||
if val ~= nil then
|
||||
local name = payload_fields[k] or k
|
||||
local transform = transform_functions[k]
|
||||
if transform ~= nil then
|
||||
msg.Fields[name] = transform(val)
|
||||
else
|
||||
msg.Fields[name] = val
|
||||
end
|
||||
end
|
||||
end
|
||||
utils.inject_tags(msg)
|
||||
|
||||
inject_message(msg)
|
||||
return 0
|
||||
end
|
|
@ -0,0 +1,98 @@
|
|||
-- Copyright 2015 Mirantis, Inc.
|
||||
--
|
||||
-- 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.
|
||||
require "string"
|
||||
local dt = require "date_time"
|
||||
local l = require 'lpeg'
|
||||
l.locale(l)
|
||||
|
||||
local syslog = require "syslog"
|
||||
local patt = require 'patterns'
|
||||
local utils = require 'lma_utils'
|
||||
|
||||
local msg = {
|
||||
Timestamp = nil,
|
||||
Type = 'log',
|
||||
Hostname = nil,
|
||||
Payload = nil,
|
||||
Pid = nil,
|
||||
Fields = nil,
|
||||
Severity = nil,
|
||||
}
|
||||
|
||||
local syslog_pattern = read_config("syslog_pattern") or error("syslog_pattern configuration must be specified")
|
||||
local syslog_grammar = syslog.build_rsyslog_grammar(syslog_pattern)
|
||||
|
||||
local sp = l.space
|
||||
local colon = l.P":"
|
||||
|
||||
local timestamp = l.Cg(patt.Timestamp, "Timestamp")
|
||||
local pid = l.Cg(patt.Pid, "Pid")
|
||||
local severity = l.Cg(patt.SeverityLabel, "SeverityLabel")
|
||||
local message = l.Cg(patt.Message, "Message")
|
||||
|
||||
-- Horizon logs have no colon after the severity level
|
||||
local openstack_grammar_5_0 = l.Ct(severity * colon^-1 * sp * message)
|
||||
local openstack_grammar_5_1 = l.Ct(timestamp * sp * pid * sp * severity * colon^-1 * sp * message)
|
||||
local openstack_grammar = openstack_grammar_5_0 + openstack_grammar_5_1
|
||||
|
||||
local neutron_grammar = l.Ct(timestamp * sp * pid * sp * severity * sp * l.Cg(patt.programname, "programname") * sp * message)
|
||||
|
||||
-- the RequestId string is enclosed between square brackets and it may be
|
||||
-- prefixed by other stuff like the Python module name.
|
||||
-- RequestId may be formatted as 'req-xxx' or 'xxx' depending on the project.
|
||||
-- UserId and TenantId may not be present depending on the OpenStack release.
|
||||
local request_grammar = (l.P(1) - "[" )^0 * "[" * l.P"req-"^-1 * l.Ct(l.Cg(patt.Uuid, "RequestId") * sp * ((l.Cg(patt.Uuid, "UserId") * sp * l.Cg(patt.Uuid, "TenantId")) + l.P(1)^0)) - "]"
|
||||
|
||||
|
||||
function process_message ()
|
||||
local log = read_message("Payload")
|
||||
local m
|
||||
|
||||
-- need to assign an empty table first otherwise
|
||||
msg.Fields = {}
|
||||
if utils.parse_syslog_message(syslog_grammar, log, msg) then
|
||||
m = openstack_grammar:match(msg.Payload)
|
||||
if m then
|
||||
if m.Pid then msg.Pid = m.Pid end
|
||||
if m.Timestamp then msg.Timestamp = m.Timestamp end
|
||||
msg.Payload = m.Message
|
||||
msg.Fields.severity_label = m.SeverityLabel
|
||||
end
|
||||
else
|
||||
-- parse with the Neutron grammar
|
||||
m = neutron_grammar:match(log)
|
||||
if m then
|
||||
msg.Timestamp = m.Timestamp
|
||||
msg.Pid = m.Pid
|
||||
msg.Payload = m.Message
|
||||
msg.Severity = utils.label_to_severity_map[m.SeverityLabel] or 5
|
||||
|
||||
msg.Fields = {}
|
||||
msg.Fields.severity_label = m.SeverityLabel
|
||||
msg.Fields.programname = m.programname
|
||||
else
|
||||
return -1
|
||||
end
|
||||
end
|
||||
|
||||
m = request_grammar:match(msg.Payload)
|
||||
if m then
|
||||
msg.Fields.request_id = m.RequestId
|
||||
if m.UserId then msg.Fields.user_id = m.UserId end
|
||||
if m.TenantId then msg.Fields.tenant_id = m.TenantId end
|
||||
end
|
||||
|
||||
inject_message(msg)
|
||||
return 0
|
||||
end
|
|
@ -0,0 +1,64 @@
|
|||
-- Copyright 2015 Mirantis, Inc.
|
||||
--
|
||||
-- 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.
|
||||
local dt = require "date_time"
|
||||
local l = require 'lpeg'
|
||||
l.locale(l)
|
||||
|
||||
local patt = require 'patterns'
|
||||
local utils = require 'lma_utils'
|
||||
|
||||
local msg = {
|
||||
Timestamp = nil,
|
||||
Type = 'log',
|
||||
Hostname = nil,
|
||||
Payload = nil,
|
||||
Pid = nil,
|
||||
Fields = nil,
|
||||
Severity = nil,
|
||||
}
|
||||
|
||||
-- RabbitMQ message logs are formatted like this:
|
||||
-- =ERROR REPORT==== 2-Jan-2015::09:17:22 ===
|
||||
-- Blabla
|
||||
-- Blabla
|
||||
--
|
||||
local message = l.Cg(patt.Message / utils.chomp, "Message")
|
||||
local severity = l.Cg(patt.SeverityLabel, "SeverityLabel")
|
||||
local day = l.R"13" * l.R"09" + l.R"19"
|
||||
local datetime = l.Cg(day, "day") * patt.dash * dt.date_mabbr * patt.dash * dt.date_fullyear *
|
||||
"::" * dt.rfc3339_partial_time
|
||||
local timestamp = l.Cg(l.Ct(datetime)/ dt.time_to_ns, "Timestamp")
|
||||
|
||||
local grammar = l.Ct("=" * severity * " REPORT==== " * timestamp * " ===" * l.P'\n' * message)
|
||||
|
||||
function process_message ()
|
||||
local log = read_message("Payload")
|
||||
|
||||
local m = grammar:match(log)
|
||||
if not m then
|
||||
return -1
|
||||
end
|
||||
|
||||
msg.Timestamp = m.Timestamp
|
||||
msg.Payload = m.Message
|
||||
msg.Severity = utils.label_to_severity_map[m.SeverityLabel] or 5
|
||||
|
||||
msg.Fields = {}
|
||||
msg.Fields.severity_label = m.SeverityLabel
|
||||
msg.Fields.programname = 'rabbitmq'
|
||||
utils.inject_tags(msg)
|
||||
|
||||
inject_message(msg)
|
||||
return 0
|
||||
end
|
|
@ -0,0 +1,63 @@
|
|||
-- Copyright 2015 Mirantis, Inc.
|
||||
--
|
||||
-- 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.
|
||||
require "circular_buffer"
|
||||
require "string"
|
||||
local alert = require "alert"
|
||||
local annotation = require "annotation"
|
||||
local anomaly = require "anomaly"
|
||||
|
||||
local title = "Severity stats"
|
||||
local rows = read_config("rows") or 1440
|
||||
local sec_per_row = read_config("sec_per_row") or 60 -- message count per minute
|
||||
local anomaly_config = anomaly.parse_config(read_config("anomaly_config"))
|
||||
annotation.set_prune(title, rows * sec_per_row * 1e9)
|
||||
|
||||
cbuf = circular_buffer.new(rows, 3, sec_per_row)
|
||||
|
||||
local INFO = cbuf:set_header(1, "INFO and lower", "count")
|
||||
local WARNING = cbuf:set_header(2, "WARNING", "count")
|
||||
local ERROR = cbuf:set_header(3, "ERROR and higher", "count")
|
||||
|
||||
local severity_to_cbuf_index = {
|
||||
[0] = ERROR,
|
||||
[1] = ERROR,
|
||||
[2] = ERROR,
|
||||
[3] = ERROR,
|
||||
[4] = WARNING,
|
||||
[5] = INFO,
|
||||
[6] = INFO ,
|
||||
[7] = INFO,
|
||||
}
|
||||
|
||||
function process_message ()
|
||||
local ts = read_message("Timestamp")
|
||||
local severity = read_message("Severity")
|
||||
cbuf:add(ts, severity_to_cbuf_index[severity], 1)
|
||||
return 0
|
||||
end
|
||||
|
||||
function timer_event(ns)
|
||||
if anomaly_config then
|
||||
if not alert.throttled(ns) then
|
||||
local msg, annos = anomaly.detect(ns, title, cbuf, anomaly_config)
|
||||
if msg then
|
||||
annotation.concat(title, annos)
|
||||
alert.send(ns, msg)
|
||||
end
|
||||
end
|
||||
inject_payload("cbuf", title, annotation.prune(title, ns), cbuf)
|
||||
else
|
||||
inject_payload("cbuf", title, cbuf)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,24 @@
|
|||
class lma_collector::elasticsearch (
|
||||
$server = $lma_collector::params::elasticsearch_server,
|
||||
$port = $lma_collector::params::elasticsearch_port,
|
||||
) {
|
||||
include lma_collector::params
|
||||
|
||||
validate_string($server)
|
||||
|
||||
heka::encoder::es_json { 'elasticsearch':
|
||||
config_dir => $lma_collector::params::config_dir,
|
||||
index => "%{Type}-%{2006.01.02}",
|
||||
es_index_from_timestamp => true,
|
||||
notify => Service[$lma_collector::params::service_name],
|
||||
}
|
||||
|
||||
heka::output::elasticsearch { 'elasticsearch':
|
||||
config_dir => $lma_collector::params::config_dir,
|
||||
server => $server,
|
||||
port => $port,
|
||||
message_matcher => "Type == 'log'",
|
||||
require => Heka::Encoder::Es_json['elasticsearch'],
|
||||
notify => Service[$lma_collector::params::service_name],
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
# == Class: lma_collector
|
||||
#
|
||||
# The lma_collector class is able to install the common componentns for running
|
||||
# the Logging, Monitoring and Alerting collector service.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# === Examples
|
||||
#
|
||||
# === Authors
|
||||
#
|
||||
# Simon Pasquier <spasquier@mirantis.com>
|
||||
#
|
||||
# === Copyright
|
||||
#
|
||||
# Copyright 2015 Mirantis Inc., unless otherwise noted.
|
||||
#
|
||||
class lma_collector (
|
||||
$tags = $lma_collector::params::tags,
|
||||
) inherits lma_collector::params {
|
||||
include heka::params
|
||||
|
||||
validate_hash($tags)
|
||||
|
||||
$service_name = $lma_collector::params::service_name
|
||||
$config_dir = $lma_collector::params::config_dir
|
||||
$plugins_dir = $lma_collector::params::plugins_dir
|
||||
$lua_modules_dir = $heka::params::lua_modules_dir
|
||||
|
||||
class { 'heka':
|
||||
service_name => $service_name,
|
||||
config_dir => $config_dir,
|
||||
run_as_root => $lma_collector::params::run_as_root,
|
||||
additional_groups => $lma_collector::params::groups,
|
||||
hostname => $::hostname,
|
||||
dashboard_address => '127.0.0.1',
|
||||
}
|
||||
|
||||
file { "${lua_modules_dir}/lma_utils.lua":
|
||||
ensure => directory,
|
||||
source => 'puppet:///modules/lma_collector/plugins/common/lma_utils.lua',
|
||||
require => File[$lua_modules_dir],
|
||||
notify => Service[$service_name],
|
||||
}
|
||||
|
||||
file { "${lua_modules_dir}/patterns.lua":
|
||||
ensure => directory,
|
||||
source => 'puppet:///modules/lma_collector/plugins/common/patterns.lua',
|
||||
require => File[$lua_modules_dir],
|
||||
notify => Service[$service_name],
|
||||
}
|
||||
|
||||
file { "${lua_modules_dir}/extra_fields.lua":
|
||||
ensure => present,
|
||||
content => template('lma_collector/extra_fields.lua.erb'),
|
||||
require => File[$lua_modules_dir],
|
||||
notify => Service[$service_name],
|
||||
}
|
||||
|
||||
file { $plugins_dir:
|
||||
ensure => directory,
|
||||
}
|
||||
|
||||
file { "${plugins_dir}/decoders":
|
||||
ensure => directory,
|
||||
source => 'puppet:///modules/lma_collector/plugins/decoders',
|
||||
recurse => remote,
|
||||
notify => Service[$service_name],
|
||||
require => File[$plugins_dir]
|
||||
}
|
||||
|
||||
file { "${plugins_dir}/filters":
|
||||
ensure => directory,
|
||||
source => 'puppet:///modules/lma_collector/plugins/filters',
|
||||
recurse => remote,
|
||||
notify => Service[$service_name],
|
||||
require => File[$plugins_dir]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
class lma_collector::logs::monitor {
|
||||
include lma_collector::params
|
||||
|
||||
heka::filter::sandbox { 'log_monitor':
|
||||
config_dir => $lma_collector::params::config_dir,
|
||||
filename => "${lma_collector::plugins_dir}/filters/log_monitor.lua" ,
|
||||
message_matcher => "Type == 'log'",
|
||||
ticker_interval => 60,
|
||||
notify => Service[$lma_collector::params::service_name],
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
class lma_collector::logs::mysql {
|
||||
include lma_collector::params
|
||||
|
||||
heka::decoder::sandbox { 'mysql':
|
||||
config_dir => $lma_collector::params::config_dir,
|
||||
filename => "${lma_collector::plugins_dir}/decoders/mysql_log.lua" ,
|
||||
config => {
|
||||
syslog_pattern => $lma_collector::params::syslog_pattern
|
||||
},
|
||||
notify => Service[$lma_collector::params::service_name],
|
||||
}
|
||||
|
||||
heka::input::logstreamer { 'mysql':
|
||||
config_dir => $lma_collector::params::config_dir,
|
||||
decoder => 'mysql',
|
||||
file_match => 'mysqld\.log$',
|
||||
differentiator => "['mysql']",
|
||||
require => Heka::Decoder::Sandbox['mysql'],
|
||||
notify => Service[$lma_collector::params::service_name],
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
class lma_collector::logs::openstack {
|
||||
include lma_collector::params
|
||||
|
||||
heka::decoder::sandbox { 'openstack':
|
||||
config_dir => $lma_collector::params::config_dir,
|
||||
filename => "${lma_collector::plugins_dir}/decoders/openstack_log.lua" ,
|
||||
config => {
|
||||
syslog_pattern => $lma_collector::params::syslog_pattern
|
||||
},
|
||||
notify => Service[$lma_collector::params::service_name],
|
||||
}
|
||||
|
||||
# Use the <PRI> token as the delimiter because OpenStack services may log
|
||||
# messages with newlines and the configuration of the Syslog daemon doesn't
|
||||
# escape them.
|
||||
heka::splitter::regex { 'openstack':
|
||||
config_dir => $lma_collector::params::config_dir,
|
||||
delimiter => '(<[0-9]+>)',
|
||||
delimiter_eol => false,
|
||||
notify => Service[$lma_collector::params::service_name],
|
||||
}
|
||||
|
||||
heka::input::logstreamer { 'openstack':
|
||||
config_dir => $lma_collector::params::config_dir,
|
||||
decoder => 'openstack',
|
||||
splitter => 'openstack',
|
||||
file_match => '(?P<Service>nova|cinder|keystone|glance|heat|neutron)-all\.log$',
|
||||
differentiator => "[ 'openstack.', 'Service' ]",
|
||||
require => [Heka::Decoder::Sandbox['openstack'], Heka::Splitter::Regex['openstack']],
|
||||
notify => Service[$lma_collector::params::service_name],
|
||||
}
|
||||
|
||||
heka::input::logstreamer { 'openstack_dashboard':
|
||||
config_dir => $lma_collector::params::config_dir,
|
||||
decoder => 'openstack',
|
||||
file_match => 'dashboard\.log$',
|
||||
differentiator => "[ 'openstack.horizon' ]",
|
||||
require => Heka::Decoder::Sandbox['openstack'],
|
||||
notify => Service[$lma_collector::params::service_name],
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
class lma_collector::logs::pacemaker {
|
||||
include lma_collector::params
|
||||
|
||||
heka::decoder::sandbox { 'pacemaker':
|
||||
config_dir => $lma_collector::params::config_dir,
|
||||
filename => "${lma_collector::plugins_dir}/decoders/generic_syslog.lua" ,
|
||||
config => {
|
||||
syslog_pattern => $lma_collector::params::syslog_pattern
|
||||
},
|
||||
notify => Service[$lma_collector::params::service_name],
|
||||
}
|
||||
|
||||
# Use the <PRI> token as the delimiter because Pacemaker may log messages
|
||||
# with newlines and the configuration of the Syslog daemon doesn't escape
|
||||
# them.
|
||||
heka::splitter::regex { 'pacemaker':
|
||||
config_dir => $lma_collector::params::config_dir,
|
||||
delimiter => '(<[0-9]+>)',
|
||||
delimiter_eol => false,
|
||||
notify => Service[$lma_collector::params::service_name],
|
||||
}
|
||||
|
||||
heka::input::logstreamer { 'pacemaker':
|
||||
config_dir => $lma_collector::params::config_dir,
|
||||
decoder => 'pacemaker',
|
||||
splitter => 'pacemaker',
|
||||
file_match => 'pacemaker\.log$',
|
||||
differentiator => "[ 'pacemaker' ]",
|
||||
require => [Heka::Decoder::Sandbox['pacemaker'], Heka::Splitter::Regex['pacemaker']],
|
||||
notify => Service[$lma_collector::params::service_name],
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
class lma_collector::logs::rabbitmq {
|
||||
include lma_collector::params
|
||||
|
||||
heka::decoder::sandbox { 'rabbitmq':
|
||||
config_dir => $lma_collector::params::config_dir,
|
||||
filename => "${lma_collector::plugins_dir}/decoders/rabbitmq.lua" ,
|
||||
notify => Service[$lma_collector::params::service_name],
|
||||
}
|
||||
|
||||
heka::splitter::regex { 'rabbitmq':
|
||||
config_dir => $lma_collector::params::config_dir,
|
||||
delimiter => '\n(=[^=]+====)',
|
||||
delimiter_eol => false,
|
||||
notify => Service[$lma_collector::params::service_name],
|
||||
}
|
||||
|
||||
heka::input::logstreamer { 'rabbitmq':
|
||||
config_dir => $lma_collector::params::config_dir,
|
||||
decoder => 'rabbitmq',
|
||||
splitter => 'rabbitmq',
|
||||
log_directory => "/var/log/rabbitmq",
|
||||
file_match => 'rabbit@(?P<Node>.+)\.log$',
|
||||
differentiator => '["rabbitmq.", "Node"]',
|
||||
require => [Heka::Decoder::Sandbox['rabbitmq'], Heka::Splitter::Regex['rabbitmq']],
|
||||
notify => Service[$lma_collector::params::service_name],
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
class lma_collector::logs::system {
|
||||
include lma_collector::params
|
||||
|
||||
heka::decoder::sandbox { 'system':
|
||||
config_dir => $lma_collector::params::config_dir,
|
||||
filename => "${lma_collector::plugins_dir}/decoders/generic_syslog.lua" ,
|
||||
config => {
|
||||
syslog_pattern => $lma_collector::params::syslog_pattern
|
||||
},
|
||||
notify => Service[$lma_collector::params::service_name],
|
||||
}
|
||||
|
||||
heka::input::logstreamer { 'system':
|
||||
config_dir => $lma_collector::params::config_dir,
|
||||
decoder => 'system',
|
||||
file_match => '(?P<Service>daemon|cron|kern|auth)\.log$',
|
||||
differentiator => "[ 'system.', 'Service' ]",
|
||||
require => Heka::Decoder::Sandbox['system'],
|
||||
notify => Service[$lma_collector::params::service_name],
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
class lma_collector::params {
|
||||
$service_name = 'lma_collector'
|
||||
$config_dir = "/etc/${service_name}"
|
||||
$plugins_dir = "/usr/share/${service_name}"
|
||||
|
||||
$tags = {}
|
||||
|
||||
$syslog_pattern = '<%PRI%>%TIMESTAMP% %HOSTNAME% %syslogtag%%msg:::sp-if-no-1st-sp%%msg%\n'
|
||||
|
||||
# required to read the log files
|
||||
case $::osfamily {
|
||||
'Debian': {
|
||||
$run_as_root = false
|
||||
$groups = ['syslog', 'adm']
|
||||
}
|
||||
'RedHat': {
|
||||
# For CentOS, the LMA collector needs to run as root because the files
|
||||
# created by RSyslog aren't created with the correct mode for now.
|
||||
$run_as_root = true
|
||||
$groups = []
|
||||
}
|
||||
}
|
||||
|
||||
# Parameters for OpenStack notifications
|
||||
$rabbitmq_host = false
|
||||
$rabbitmq_user = ''
|
||||
$rabbitmq_password = ''
|
||||
|
||||
$elasticsearch_server = false
|
||||
$elasticsearch_port = '9200'
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"name": "lma_collector",
|
||||
"version": "6.1.0",
|
||||
"author": "Simon Pasquier <spasquier@mirantis.com>",
|
||||
"summary": "Puppet LMA Collector Module",
|
||||
"license": "Apache License 2.0",
|
||||
"source": "git://git.openstack.org/cgit/stackforge/fuel-plugin-lma-collector.git",
|
||||
"project_page": "none",
|
||||
"issues_url": "none",
|
||||
"operatingsystem_support": [
|
||||
{
|
||||
"operatingsystem": "Ubuntu",
|
||||
"operatingsystemrelease": ["12.04", "14.04"]
|
||||
},
|
||||
{
|
||||
"operatingsystem": "CentOS",
|
||||
"operatingsystemrelease": ["6"]
|
||||
}
|
||||
],
|
||||
"description": "Puppet module for configuring the LMA collector service",
|
||||
"dependencies": [
|
||||
{"name": "puppetlabs/stdlib", "version_requirement": "4.x"},
|
||||
{"name": "pdxcat/collectd", "version_requirement": "3.x"},
|
||||
{"name": "mirantis/heka", "version_requirement": "1.x"}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
dir = File.expand_path(File.dirname(__FILE__))
|
||||
$LOAD_PATH.unshift File.join(dir, 'lib')
|
||||
|
||||
require 'mocha'
|
||||
require 'puppet'
|
||||
require 'rspec'
|
||||
require 'spec/autorun'
|
||||
|
||||
Spec::Runner.configure do |config|
|
||||
config.mock_with :mocha
|
||||
end
|
||||
|
||||
# We need this because the RAL uses 'should' as a method. This
|
||||
# allows us the same behaviour but with a different method name.
|
||||
class Object
|
||||
alias :must :should
|
||||
end
|
|
@ -0,0 +1,24 @@
|
|||
-- Copyright 2015 Mirantis, Inc.
|
||||
--
|
||||
-- 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.
|
||||
local M = {}
|
||||
setfenv(1, M) -- Remove external access to contain everything in the module
|
||||
|
||||
-- list of fields that are added to Heka messages by the collector
|
||||
tags = {
|
||||
<% @tags.each do |k,v| -%>
|
||||
['<%= k.gsub("'"){"\\'"} %>'] = '<%= v.gsub("'"){"\\'"} %>',
|
||||
<% end -%>
|
||||
}
|
||||
|
||||
return M
|
|
@ -0,0 +1,12 @@
|
|||
# The baseline for module testing used by Puppet Labs is that each manifest
|
||||
# should have a corresponding test manifest that declares that class or defined
|
||||
# type.
|
||||
#
|
||||
# Tests are then run by using puppet apply --noop (to check for compilation
|
||||
# errors and view a log of events) or by fully applying the test in a virtual
|
||||
# environment (to compare the resulting system state to the desired state).
|
||||
#
|
||||
# Learn more about module testing here:
|
||||
# http://docs.puppetlabs.com/guides/tests_smoke.html
|
||||
#
|
||||
include lma_collector
|
|
@ -0,0 +1,63 @@
|
|||
$fuel_settings = parseyaml(file('/etc/astute.yaml'))
|
||||
|
||||
$deployment_mode = $fuel_settings['deployment_mode']
|
||||
if $deployment_mode == 'multinode' {
|
||||
$controller_role = 'controller'
|
||||
}
|
||||
elsif $deployment_mode =~ /^ha/ {
|
||||
$controller_role = 'primary-controller'
|
||||
}
|
||||
else {
|
||||
fail ("'${deployment_mode} is not a supported deployment mode")
|
||||
}
|
||||
|
||||
# TODO: verify that we're running Neutron
|
||||
|
||||
$roles = node_roles($fuel_settings['nodes'], $fuel_settings['uid'])
|
||||
$is_primary_controller = member($roles, $controller_role)
|
||||
$is_controller = member($roles, 'controller')
|
||||
|
||||
if $fuel_settings['rabbit']['user'] {
|
||||
$rabbitmq_user = $fuel_settings['rabbit']['user']
|
||||
}
|
||||
else {
|
||||
$rabbitmq_user = 'nova'
|
||||
}
|
||||
|
||||
class lma_common {
|
||||
class { 'lma_collector':
|
||||
tags => {
|
||||
fuel_environment => $fuel_settings['lma_collector']['fuel_environment'],
|
||||
openstack_region => 'RegionOne',
|
||||
openstack_release => $fuel_settings['openstack_version'],
|
||||
openstack_roles => join($roles, ","),
|
||||
deployment_mode => $deployment_mode,
|
||||
}
|
||||
}
|
||||
|
||||
class { 'lma_collector::logs::system': }
|
||||
|
||||
class { 'lma_collector::logs::openstack': }
|
||||
|
||||
class { 'lma_collector::logs::monitor': }
|
||||
}
|
||||
|
||||
class lma_controller {
|
||||
class { 'lma_collector::logs::mysql': }
|
||||
|
||||
class { 'lma_collector::logs::rabbitmq': }
|
||||
|
||||
class { 'lma_collector::logs::pacemaker': }
|
||||
}
|
||||
|
||||
if $fuel_settings['lma_collector']['elasticsearch_server'] != '' {
|
||||
class { 'lma_common': }
|
||||
|
||||
if ($is_primary_controller or $is_controller) {
|
||||
class { 'lma_controller': }
|
||||
}
|
||||
|
||||
class { 'lma_collector::elasticsearch':
|
||||
server => $fuel_settings['lma_collector']['elasticsearch_server']
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
attributes:
|
||||
metadata:
|
||||
restrictions:
|
||||
- condition: "cluster:net_provider != 'neutron'"
|
||||
action: "hide"
|
||||
|
||||
# TODO(pasquier-s): validate input fields
|
||||
fuel_environment:
|
||||
value: ''
|
||||
label: 'Environment name'
|
||||
description: 'Name of the environment as reported in the collected data.'
|
||||
weight: 10
|
||||
type: "text"
|
||||
|
||||
# TODO(pasquier-s): validate input fields
|
||||
elasticsearch_server:
|
||||
value: ''
|
||||
label: 'ElasticSearch server'
|
||||
description: 'Leave empty if you''re not using ElasticSearch.'
|
||||
weight: 30
|
||||
type: "text"
|
|
@ -0,0 +1,36 @@
|
|||
# Plugin name
|
||||
name: lma_collector
|
||||
# Human-readable name for your plugin
|
||||
title: The Logging, Monitoring and Alerting (LMA) collector
|
||||
# Plugin version
|
||||
version: 6.1.0
|
||||
# Description
|
||||
description: Collect logs, metrics and notifications from system and OpenStack services and forward that information to external backends such as ElasticSearch and InfluxDB.
|
||||
# Required fuel version
|
||||
fuel_version: ['6.0', '6.1']
|
||||
|
||||
# The plugin is compatible with releases in the list
|
||||
releases:
|
||||
- os: ubuntu
|
||||
version: 2014.2-6.0
|
||||
mode: ['ha', 'multinode']
|
||||
deployment_scripts_path: deployment_scripts/
|
||||
repository_path: repositories/ubuntu
|
||||
- os: ubuntu
|
||||
version: 2014.2-6.1
|
||||
mode: ['ha', 'multinode']
|
||||
deployment_scripts_path: deployment_scripts/
|
||||
repository_path: repositories/ubuntu
|
||||
- os: centos
|
||||
version: 2014.2-6.0
|
||||
mode: ['ha', 'multinode']
|
||||
deployment_scripts_path: deployment_scripts/
|
||||
repository_path: repositories/centos
|
||||
- os: centos
|
||||
version: 2014.2-6.1
|
||||
mode: ['ha', 'multinode']
|
||||
deployment_scripts_path: deployment_scripts/
|
||||
repository_path: repositories/centos
|
||||
|
||||
# Version of plugin package
|
||||
package_version: '1.0.0'
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
set -eux
|
||||
|
||||
ROOT="$(dirname `readlink -f $0`)"
|
||||
MODULES="${ROOT}"/deployment_scripts/puppet/modules
|
||||
RPM_REPO="${ROOT}"/repositories/centos/
|
||||
DEB_REPO="${ROOT}"/repositories/ubuntu/
|
||||
HEKA_VERSION="0.9.0"
|
||||
# The following commit is the id for the 6.0 tag
|
||||
FUEL_LIB_SHA1="b977b77b7e1fca1f38e701373601e9fe3430eaee"
|
||||
FUEL_LIB_TARBALL_URL="https://github.com/stackforge/fuel-library/tarball/${FUEL_LIB_SHA1}"
|
||||
|
||||
# Clean-up first
|
||||
rm -rf ${MODULES}/{stdlib,openstack}/
|
||||
|
||||
wget -qO - https://github.com/mozilla-services/heka/releases/download/v${HEKA_VERSION}/heka_${HEKA_VERSION}_amd64.deb > ${DEB_REPO}/heka_${HEKA_VERSION}_amd64.deb
|
||||
wget -qO - https://github.com/mozilla-services/heka/releases/download/v${HEKA_VERSION}/heka-${HEKA_VERSION//./_}-linux-amd64.rpm > ${RPM_REPO}/heka-${HEKA_VERSION//./_}-linux-amd64.rpm
|
||||
|
||||
# Include dependent manifests from fuel-library
|
||||
wget -qO- "${FUEL_LIB_TARBALL_URL}" | \
|
||||
tar -C "${MODULES}" --strip-components=3 -zxvf - \
|
||||
stackforge-fuel-library-${FUEL_LIB_SHA1:0:7}/deployment/puppet/{stdlib,keystone,openstack}
|
|
@ -0,0 +1,7 @@
|
|||
- role: ['controller', 'compute', 'cinder']
|
||||
stage: post_deployment
|
||||
type: puppet
|
||||
parameters:
|
||||
puppet_manifest: puppet/site.pp
|
||||
puppet_modules: puppet/modules
|
||||
timeout: 600
|
Loading…
Reference in New Issue