Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scheme to loki client #293

Closed
sed-i opened this issue Jul 26, 2023 · 2 comments · Fixed by #296
Closed

Add scheme to loki client #293

sed-i opened this issue Jul 26, 2023 · 2 comments · Fixed by #296

Comments

@sed-i
Copy link
Contributor

sed-i commented Jul 26, 2023

Currently the client code has http hard-coded:

self.base_url = f"http://{self.host}:{self.port}"

Ref: https://github.com/canonical/prometheus-k8s-operator/blob/d33f51f39d990de3b8dcb9436bf69291a8e8b891/src/prometheus_client.py#L20

@Abuelodelanada
Copy link
Contributor

We do not need TLS for this.
This is almost dead code. Right now we are using self.base_url to get the build_info through a request:

def _build_info(self):

And with that build_info we get Loki's version:

def version(self) -> str:

We can get Loki's version using the binary. An example of this in Grafana agent:

    def agent_version_output(self) -> str:
        """Runs `agent -version` and returns the output.

        Returns:
            Output of `agent -version`
        """
        version_output, _ = self._container.exec(["/bin/agent", "-version"]).wait_output()
        return version_output

@Abuelodelanada
Copy link
Contributor

This is definitely dead code, we are in fact using:

https://github.com/canonical/loki-k8s-operator/blob/main/src/charm.py#L509

    @property
    def _loki_version(self) -> Optional[str]:
        """Returns the version of Loki.

        Returns:
            A string equal to the Loki version
        """
        if not self._container.can_connect():
            return None
        version_output, _ = self._container.exec(["/usr/bin/loki", "-version"]).wait_output()
        # Output looks like this:
        # loki, version 2.4.1 (branch: HEAD, ...
        result = re.search(r"version (\d*\.\d*\.\d*)", version_output)
        if result is None:
            return result
        return result.group(1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants