1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

add job_id to fact cache log output

This commit is contained in:
Chris Meyers 2018-01-17 09:27:01 -05:00
parent 1a98cedc0f
commit e33265e12c
3 changed files with 8 additions and 1 deletions

View File

@ -812,7 +812,8 @@ class Job(UnifiedJob, JobOptions, SurveyJobMixin, JobNotificationMixin, TaskMana
smart_str(host.inventory.name), smart_str(host.name)), smart_str(host.inventory.name), smart_str(host.name)),
extra=dict(inventory_id=host.inventory.id, host_name=host.name, extra=dict(inventory_id=host.inventory.id, host_name=host.name,
ansible_facts=host.ansible_facts, ansible_facts=host.ansible_facts,
ansible_facts_modified=host.ansible_facts_modified.isoformat())) ansible_facts_modified=host.ansible_facts_modified.isoformat(),
job_id=self.id))
# Add on aliases for the non-related-model fields # Add on aliases for the non-related-model fields

View File

@ -162,6 +162,7 @@ def test_base_logging_handler_emit_system_tracking():
) )
record.inventory_id = 11 record.inventory_id = 11
record.host_name = 'my_lucky_host' record.host_name = 'my_lucky_host'
record.job_id = 777
record.ansible_facts = { record.ansible_facts = {
"ansible_kernel": "4.4.66-boot2docker", "ansible_kernel": "4.4.66-boot2docker",
"ansible_machine": "x86_64", "ansible_machine": "x86_64",
@ -172,8 +173,12 @@ def test_base_logging_handler_emit_system_tracking():
assert len(sent_payloads) == 1 assert len(sent_payloads) == 1
assert sent_payloads[0]['ansible_facts'] == record.ansible_facts assert sent_payloads[0]['ansible_facts'] == record.ansible_facts
assert sent_payloads[0]['ansible_facts_modified'] == record.ansible_facts_modified
assert sent_payloads[0]['level'] == 'INFO' assert sent_payloads[0]['level'] == 'INFO'
assert sent_payloads[0]['logger_name'] == 'awx.analytics.system_tracking' assert sent_payloads[0]['logger_name'] == 'awx.analytics.system_tracking'
assert sent_payloads[0]['job_id'] == record.job_id
assert sent_payloads[0]['inventory_id'] == record.inventory_id
assert sent_payloads[0]['host_name'] == record.host_name
@pytest.mark.parametrize('host, port, normalized, hostname_only', [ @pytest.mark.parametrize('host, port, normalized, hostname_only', [

View File

@ -111,6 +111,7 @@ class LogstashFormatter(LogstashFormatterVersion1):
data_for_log['ansible_facts_modified'] = raw_data['ansible_facts_modified'] data_for_log['ansible_facts_modified'] = raw_data['ansible_facts_modified']
data_for_log['inventory_id'] = raw_data['inventory_id'] data_for_log['inventory_id'] = raw_data['inventory_id']
data_for_log['host_name'] = raw_data['host_name'] data_for_log['host_name'] = raw_data['host_name']
data_for_log['job_id'] = raw_data['job_id']
elif kind == 'performance': elif kind == 'performance':
request = raw_data['python_objects']['request'] request = raw_data['python_objects']['request']
response = raw_data['python_objects']['response'] response = raw_data['python_objects']['response']