Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions app/vlselect/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"
"time"

"github.com/VictoriaMetrics/VictoriaMetrics/lib/buildinfo"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/cgroup"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/httpserver"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/httputil"
Expand Down Expand Up @@ -138,6 +139,27 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool {
func selectHandler(w http.ResponseWriter, r *http.Request, path string) bool {
ctx := r.Context()

if path == "/select/buildinfo" {
httpserver.EnableCORS(w, r)

if r.Method != http.MethodGet {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusMethodNotAllowed)
fmt.Fprintf(w, `{"status":"error","msg":"method %q isn't allowed"}`, r.Method)
return true
}

v := buildinfo.ShortVersion()
if v == "" {
// buildinfo.ShortVersion() may return empty result for builds without tags
v = buildinfo.Version
}

w.Header().Set("Content-Type", "application/json")
fmt.Fprintf(w, `{"status":"success","data":{"version":%q}}`, v)
return true
}

if path == "/select/vmui" {
// VMUI access via incomplete url without `/` in the end. Redirect to complete url.
// Use relative redirect, since the hostname and path prefix may be incorrect if VictoriaMetrics
Expand Down
2 changes: 2 additions & 0 deletions app/vmui/packages/vmui/src/api/buildinfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const getBuildInfoUrl = (server: string): string =>
`${server}/select/buildinfo`;
28 changes: 28 additions & 0 deletions app/vmui/packages/vmui/src/hooks/useGetVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { useAppState } from "../state/common/StateContext";
import { useEffect, useState } from "preact/compat";
import { getBuildInfoUrl } from "../api/buildinfo";

const useGetVersion = () => {
const { serverUrl } = useAppState();

const [version, setVersion] = useState("");

useEffect(() => {
const fetchVersion = async () => {
try {
const response = await fetch(getBuildInfoUrl(serverUrl));
const result = await response.json();
setVersion(result?.data?.version);
} catch (e) {
console.error(e);
}
};

fetchVersion();
}, [serverUrl]);

return { version };
};

export default useGetVersion;

5 changes: 4 additions & 1 deletion app/vmui/packages/vmui/src/layouts/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { FC, memo } from "preact/compat";
import { LogoShortIcon } from "../../components/Main/Icons";
import "./style.scss";
import { footerLinksToLogs } from "../../constants/footerLinks";
import useGetVersion from "../../hooks/useGetVersion";

interface Props {
links?: {
Expand All @@ -13,6 +14,7 @@ interface Props {

const Footer: FC<Props> = memo(({ links = footerLinksToLogs }) => {
const copyrightYears = `2019-${new Date().getFullYear()}`;
const { version } = useGetVersion();

return <footer className="vm-footer">
<a
Expand All @@ -37,7 +39,8 @@ const Footer: FC<Props> = memo(({ links = footerLinksToLogs }) => {
</a>
))}
<div className="vm-footer__copyright">
&copy; {copyrightYears} VictoriaMetrics
&copy; {copyrightYears} VictoriaMetrics.
{version && <span className="vm-footer__version">&nbsp;Version: {version}</span>}
</div>
</footer>;
});
Expand Down
2 changes: 2 additions & 0 deletions docs/victorialogs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ according to the follosing docs:

## tip

* FEATURE: [vmui](https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#vmui): show VictoriaLogs version in the vmui's footer. See [#116](https://github.com/VictoriaMetrics/VictoriaLogs/issues/116).

## [v1.39.0](https://github.com/VictoriaMetrics/VictoriaLogs/releases/tag/v1.39.0)

Released at 2025-11-29
Expand Down