def render_beat_template(): beat_dir = '/etc/dockerbeat' if not os.path.exists(beat_dir): os.makedirs(beat_dir, exist_ok=True) render_without_context('dockerbeat.yml', '/etc/dockerbeat/dockerbeat.yml') remove_state('beat.render') service_restart('dockerbeat') status_set('active', 'Dockerbeat ready')
def push_dockerbeat_index(elasticsearch): ''' Push the index to ElasticSearch so its easier to aggregate the data ''' render_without_context('dockerbeat.template.json', '/etc/dockerbeat/dockerbeat.template.json') hosts = elasticsearch.list_unit_data() for host in hosts: host_string = "{}:{}".format(host['host'], host['port']) push_beat_index(host_string, 'dockerbeat') set_state('dockerbeat.index.pushed')
def render_filebeat_template(): """Create the filebeat.yaml config file. Renders the appropriate template for the major version of filebeat that is installed. """ # kube_logs requires access to k8s-related filesystem data. If configured, # don't try to start filebeat until that data is present. if config().get('kube_logs') and not os.path.exists(KUBE_CONFIG): status.maint('Waiting for: {}'.format(KUBE_CONFIG)) return version = charms.apt.get_package_version('filebeat')[0] cfg_original_hash = file_hash(FILEBEAT_CONFIG) connections = render_without_context('filebeat-{}.yml'.format(version), FILEBEAT_CONFIG) cfg_new_hash = file_hash(FILEBEAT_CONFIG) # Ensure ssl files match config each time we render a new template manage_filebeat_logstash_ssl() remove_state('beat.render') if connections: if cfg_original_hash != cfg_new_hash: service('restart', 'filebeat') status.active('Filebeat ready.') else: # Stop the service when not connected to any log handlers. # NB: beat base layer will handle setting a waiting status service('stop', 'filebeat')
def render_filebeat_template(): connections = render_without_context('filebeat.yml', '/etc/filebeat/filebeat.yml') render_filebeat_logstash_ssl_cert() remove_state('beat.render') if connections: status_set('active', 'Filebeat ready.')
def render_filebeat_template(): """Create the filebeat.yaml config file. Renders the appropriate template for the major version of filebeat that is installed. """ # kube_logs requires access to a kubeconfig. If configured, log whether or # not we have enough to start collecting k8s metadata. if config().get('kube_logs'): if os.path.exists(KUBE_CONFIG): msg = 'Collecting k8s metadata.' else: msg = ('kube_logs=True, but {} does not exist. ' 'No k8s metadata will be collected.'.format(KUBE_CONFIG)) log(msg) # The v5 template is compatible with all versions < 6 major = charms.apt.get_package_version('filebeat')[0] version = major if major.isdigit() and int(major) > 5 else "5" cfg_original_hash = file_hash(FILEBEAT_CONFIG) connections = render_without_context('filebeat-{}.yml'.format(version), FILEBEAT_CONFIG) cfg_new_hash = file_hash(FILEBEAT_CONFIG) # Ensure ssl files match config each time we render a new template manage_filebeat_logstash_ssl() remove_state('beat.render') if connections: if cfg_original_hash != cfg_new_hash: service('restart', 'filebeat') status.active('Filebeat ready.') else: # Stop the service when not connected to any log handlers. # NB: beat base layer will handle setting a waiting status service('stop', 'filebeat')
def render_filebeat_template(): render_without_context('packetbeat.yml', '/etc/packetbeat/packetbeat.yml') remove_state('beat.render') service_restart('packetbeat') status_set('active', 'Packetbeat ready')
def render_filebeat_template(): render_without_context('filebeat.yml', '/etc/filebeat/filebeat.yml') remove_state('beat.render') status_set('active', 'Filebeat ready')
def render_topbeat_template(): render_without_context('topbeat.yml', '/etc/topbeat/topbeat.yml') remove_state('beat.render') status_set('active', 'Topbeat ready') service_restart('topbeat')
def render_topbeat_template(): connections = render_without_context('topbeat.yml', '/etc/topbeat/topbeat.yml') remove_state('beat.render') if connections: status_set('active', 'Topbeat ready.')
def render_topbeat_template(): render_without_context('topbeat.yml', '/etc/topbeat/topbeat.yml') remove_state('beat.render') status_set('active', 'Topbeat ready')