8000 [bug]: fix data explore not support namespace by stone1100 · Pull Request #982 · lindb/lindb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[bug]: fix data explore not support namespace #982

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

Merged
merged 1 commit into from
Aug 29, 2023
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
16 changes: 16 additions & 0 deletions .github/workflows/docker-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,29 @@ jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Build Web
id: web
run: |
make build-frontend
echo "web=$PWD" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: network=host
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
Expand All @@ -44,5 +58,7 @@ jobs:
platforms: ${{ env.PLATFORMS }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
context: ${{ steps.web.outputs.web }}
file: Dockerfile-gh
build-args: |
LD_FLAGS=-ldflags=-s -w -X github.com/lindb/lindb/config.Version=latest -X github.com/lindb/lindb/config.BuildTime=${{ steps.date.outputs.date }}
16 changes: 14 additions & 2 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,24 @@ jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 1
ref: ${{ github.ref }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Build Web
id: web
run: |
make build-frontend
echo "web=$PWD" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
Expand All @@ -42,11 +54,11 @@ jobs:
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
file: ./Dockerfile-gh
push: true
platforms: ${{ env.PLATFORMS }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
context: ${{ steps.web.outputs.web }}
build-args: |
LD_FLAGS=-ldflags=-s -w -X github.com/lindb/lindb/config.Version=${{ github.ref_name }} -X github.com/lindb/lindb/config.BuildTime=${{ steps.date.outputs.date }}
39 changes: 39 additions & 0 deletions Dockerfile-gh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Build the manager binary
FROM golang:1.19 as go_builder
ARG TARGETOS
ARG TARGETARCH
ARG LD_FLAGS

WORKDIR /go_workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy src code
COPY . .

# Copy web static resource
COPY ${GITHUB_WORKSPACE}/web/static/ web/static

# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} \
go build "${LD_FLAGS}" -o lind ./cmd/lind \
&& go build "${LD_FLAGS}" -o lindctl ./cmd/cli

FROM centos:latest
WORKDIR /
COPY --from=go_builder /go_workspace/lind /usr/bin/lind
COPY --from=go_builder /go_workspace/lindctl /usr/bin/lindctl
RUN ln -s /usr/bin/lind /usr/local/bin/lind
RUN ln -s /usr/bin/lindctl /usr/local/bin/lindctl
RUN mkdir /etc/lindb
RUN mkdir /data

USER 0:0
6 changes: 6 additions & 0 deletions web/src/components/data/MetadataSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ const MetadataSelect: React.FC<{
whereClause.push(...tags);
}
}
// set namespace
const namespace = _.get(params, "namespace");
if (!_.isEmpty(namespace)) {
targetSQL += ` on '${namespace}'`;
}

if (!_.isEmpty(whereClause)) {
targetSQL += ` where ${whereClause.join(" and ")}`;
}
Expand Down
10 changes: 7 additions & 3 deletions web/src/components/data/TagFilterSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ export default function TagFilterSelect(props: {
const fetchTagKeys = async () => {
const metadata = await ExecService.exec<Metadata>({
db: db,
sql: `show tag keys from '${metric}'`,
sql: `show tag keys from '${metric}'${
namespace ? ` on '${namespace}'` : ""
}`,
});
const tagKeys = (metadata as Metadata).values || [];
setTagKeys(tagKeys as string[]);
};
fetchTagKeys();
}, [db, metric]);
}, [db, metric, namespace]);

return (
<Popover
Expand All @@ -73,7 +75,9 @@ export default function TagFilterSelect(props: {
db: db,
tagKey: tagKey,
label: tagKey,
sql: `show tag values from '${metric}' with key='${tagKey}'`,
sql: `show tag values from '${metric}' ${
namespace ? ` on '${namespace}'` : ""
} with key='${tagKey}'`,
}}
labelPosition="inset"
/>
Expand Down
15 changes: 13 additions & 2 deletions web/src/pages/search/DataExplore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ const ExploreForm: React.FC = () => {
};

const MetricMetaForm: React.FC = () => {
const { db, metric, tags } = useParams(["db", "metric", "tags"]);
const { db, metric, namespace, tags } = useParams([
"db",
"metric",
"namespace",
"tags",
]);
const formApi = useRef() as MutableRefObject<any>;
const [tagFilter, setTagFilter] = useState<Object>();
const { locale } = useContext(UIContext);
Expand Down Expand Up @@ -164,7 +169,13 @@ const MetricMetaForm: React.FC = () => {
});
}
}}
suffix={<TagFilterSelect db={db || ""} metric={metric || ""} />}
suffix={
<TagFilterSelect
db={db || ""}
metric={metric || ""}
namespace={namespace}
/>
}
/>
<MetadataSelect
variate={{
Expand Down
0