Uploaded image for project: 'Ansible Automation Platform RFEs'
  1. Ansible Automation Platform RFEs
  2. AAPRFE-1575

Improve the logger for gather_analytics to help on further TS at AA kibana.

XMLWordPrintable

    • Icon: Feature Request Feature Request
    • Resolution: Unresolved
    • Icon: Undefined Undefined
    • None
    • 2.4
    • automation-analytics
    • None
    • False
    • Hide

      None

      Show
      None
    • False

      We were working on a case where the customer is having issues to see the tarball generated by the `gather_analytics` being digested by the Ansible Analytics at console.redhat.com.

       

      We have worked with AA team, and they have provided a bunch of logs, however, we could not match until configure gather_analytics to print the request_id, account_number, and org_id.

       

      To do that, we have changed the core.py file, including the following lines at `ship` function.

      def ship(path):
          """
          Ship gathered metrics to the Insights API
          """
          if not path:
              logger.error('Automation Analytics TAR not found')
              return False
          if not os.path.exists(path):
              logger.error('Automation Analytics TAR {} not found'.format(path))
              return False
          if "Error:" in str(path):
              return False    logger.debug('shipping analytics file: {}'.format(path))
          url = getattr(settings, 'AUTOMATION_ANALYTICS_URL', None)
          if not url:
              logger.error('AUTOMATION_ANALYTICS_URL is not set')
              return False
          rh_user = getattr(settings, 'REDHAT_USERNAME', None)
          rh_password = getattr(settings, 'REDHAT_PASSWORD', None)
          if not rh_user:
              logger.error('REDHAT_USERNAME is not set')
              return False
          if not rh_password:
              logger.error('REDHAT_PASSWORD is not set')
              return False
          with open(path, 'rb') as f:
              files = {'file': (os.path.basename(path), f, settings.INSIGHTS_AGENT_MIME)}
              s = requests.Session()
              s.headers = get_awx_http_client_headers()
              s.headers.pop('Content-Type')
              with set_environ(**settings.AWX_TASK_ENV):
                  response = s.post(url, files=files, verify=settings.INSIGHTS_CERT_PATH, auth=(rh_user, rh_password), headers=s.headers, timeout=(31, 31))
                  logger.info(os.path.basename(path)) <==== HERE
                  logger.info(response.text)        <==== HERE
              # Accept 2XX status_codes
              if response.status_code >= 300:
                  logger.error('Upload failed with status {}, {}'.format(response.status_code, response.text))
                  return False        return True 

       

      It generated the following logs at `/var/log/tower/task_system.log`

       

      2024-09-26 22:54:56,003 INFO     [-] awx.main.analytics 5d731618-9623-4cc5-a2ed-9963fa00b3f0-2024-09-26-225449+0000-0.tar.gz
      2024-09-26 22:54:56,005 INFO     [-] awx.main.analytics {'request_id': '11d1de8698c1464b98568e618b2c8e37', 'upload': {'account_number': '540155', 'org_id': '1979710'}}
      2024-09-26 22:55:02,172 INFO     [-] awx.main.analytics 5d731618-9623-4cc5-a2ed-9963fa00b3f0-2024-09-26-225449+0000-1.tar.gz
      2024-09-26 22:55:02,174 INFO     [-] awx.main.analytics {'request_id': 'e609726b52fc489b825ed76609e08b06', 'upload': {'account_number': '540155', 'org_id': '1979710'}}
      2024-09-26 22:55:08,295 INFO     [-] awx.main.analytics 5d731618-9623-4cc5-a2ed-9963fa00b3f0-2024-09-26-225449+0000-2.tar.gz
      2024-09-26 22:55:08,297 INFO     [-] awx.main.analytics {'request_id': '9f80106d22fa4b89b4cc229cf0a7b296', 'upload': {'account_number': '540155', 'org_id': '1979710'}}
      2024-09-26 22:55:14,496 INFO     [-] awx.main.analytics 5d731618-9623-4cc5-a2ed-9963fa00b3f0-2024-09-26-225449+0000-3.tar.gz
      2024-09-26 22:55:14,497 INFO     [-] awx.main.analytics {'request_id': '1ae1ed01b99e422d96740c033d8b324b', 'upload': {'account_number': '540155', 'org_id': '1979710'}}

       

      Once we have the request_id, we can check if it being digested by AA logs at kibana.

       

              jhardy@redhat.com John Hardy
              rhn-support-rbertolj Rudnei Bertol Junior
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: