question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Links to Stackdriver in WebUI

See original GitHub issue

Description

We currently have integration between web UI and Elasticsearch. It was added by this PR: https://github.com/apache/airflow/pull/5164 This allows easier access to the Elasticsearch interface. We recently added a task handler that allows you to save logs to the Stackdriver service https://github.com/apache/airflow/pull/6660 I would be happy if a similar button also appears when StackdriverTaskHandler is used. Stackdriver has a much more friendly interface than Airflow, so access to it would be very helpful. It is also a fully managed service, so anyone can use it very easily.

To generate the Stackdriver URL, you can use the following code:

    LOG_VIEWER_BASE_URL = "https://console.cloud.google.com/logs/viewer"

    @property
    def _resource_path(self):
        segments = [self.resource.type]

        for key, value in self.resource.labels:
            segments += [key]
            segments += [value]

        return "/".join(segments)

    def get_external_log_url(self, task_instance: TaskInstance, try_number: int) -> str:
        """
        Creates an address for an external log collecting service.
        :param task_instance: task instance object
        :type: task_instance: TaskInstance
        :param try_number: task instance try_number to read logs from.
        :type try_number: Optional[int]
        :return: URL to the external log collection service
        :rtype: str
        """
        project_id = self._client.project

        ti_labels = self._task_instance_to_labels(task_instance)
        ti_labels[self.LABEL_TRY_NUMBER] = str(try_number)

        log_filter = self._prepare_log_filter(ti_labels)

        url_query_string = {
            'project': project_id,
            'interval': 'NO_LIMIT',
            'resource': self._resource_path,
            'advancedFilter': log_filter,
        }

        url = f"{self.LOG_VIEWER_BASE_URL}?{urllib.parse.urlencode(url_query_string)}"
        return url

Before making this change, I think it’s worth adding the missing tests PR, which added external links for Elasticsearch does not introduce any new tests, so it is advisable to supplement them before starting work. You can use capture_templates method to do it. https://github.com/apache/airflow/pull/8505

If anyone is interested in this task, I am willing to provide all the necessary tips and information.

If you haven’t used the GCP yet, after creating the account you will get $300, which will allow you to test change and get to know this service better.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

3reactions
ashbcommented, Jun 15, 2020

We should ideally do this such that any of the task logging handlers could provide custom log links – i.e. don’t just hard code support for ES or StackDriver in to the UI.

1reaction
mik-lajcommented, Jul 11, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Cluster web interfaces - Dataproc - Google Cloud
This connection method allows you to connect to multiple ports on a cluster web interface. See Can I use local port forwarding instead...
Read more >
Enable Google Stackdriver Monitoring on the VM Series Firewall
Monitor PAN-OS metrics from Google® Stackdriver. ... Log in to the web interface on the VM-Series firewall. Select. Device. VM-Series.
Read more >
Stackdriver logs written by Cloud Run application are tricky to ...
I expected to see stackdriver logs in "Logs Viewer" section of cloud console, or in "Logs" tab of service's Cloud Run section. ......
Read more >
Monitoring and alerting on bytes sent from Google Cloud ...
In this article, I'll show you how to set up monitoring and alerting for this metric in the Google Cloud web UI. How...
Read more >
Running a query with the BigQuery web UI - YouTube
In this video, you will learn how to write and run queries from BigQuery tables directly in the BigQuery web UI. As you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found