2 Commits

Author SHA1 Message Date
887f450cf8 update: conn to es add 5s timeout 2024-03-26 17:16:11 +08:00
77f0bbebe2 fix: github action 2024-03-26 13:32:08 +08:00
4 changed files with 31 additions and 17 deletions

View File

@ -13,10 +13,13 @@ jobs:
pull-requests: write pull-requests: write
repository-projects: write repository-projects: write
steps: steps:
- name: checkout repository
uses: actions/checkout@v4
- name: install golang - name: install golang
uses: actions/setup-go@v4 uses: actions/setup-go@v4
with: with:
go-version: '1.20' go-version: '1.18'
- name: build linux amd64 - name: build linux amd64
run: CGO_ENABLE=0 GOOS=linux GOARCH=amd64 go build -ldflags='-s -w' -o dist/esgo2dump_${{ github.ref_name }}_linux_amd64 . run: CGO_ENABLE=0 GOOS=linux GOARCH=amd64 go build -ldflags='-s -w' -o dist/esgo2dump_${{ github.ref_name }}_linux_amd64 .
@ -27,6 +30,9 @@ jobs:
- name: build windows amd64 - name: build windows amd64
run: CGO_ENABLE=0 GOOS=windows GOARCH=amd64 go build -ldflags='-s -w' -o dist/esgo2dump_${{ github.ref_name }}_windows_amd64.exe . run: CGO_ENABLE=0 GOOS=windows GOARCH=amd64 go build -ldflags='-s -w' -o dist/esgo2dump_${{ github.ref_name }}_windows_amd64.exe .
- name: build windows arm64
run: CGO_ENABLE=0 GOOS=windows GOARCH=arm64 go build -ldflags='-s -w' -o dist/esgo2dump_${{ github.ref_name }}_windows_arm64.exe .
- name: build darwin amd64 - name: build darwin amd64
run: CGO_ENABLE=0 GOOS=darwin GOARCH=amd64 go build -ldflags='-s -w' -o dist/esgo2dump_${{ github.ref_name }}_darwin_amd64 . run: CGO_ENABLE=0 GOOS=darwin GOARCH=amd64 go build -ldflags='-s -w' -o dist/esgo2dump_${{ github.ref_name }}_darwin_amd64 .
@ -34,7 +40,7 @@ jobs:
run: CGO_ENABLE=0 GOOS=darwin GOARCH=arm64 go build -ldflags='-s -w' -o dist/esgo2dump_${{ github.ref_name }}_darwin_arm64 . run: CGO_ENABLE=0 GOOS=darwin GOARCH=arm64 go build -ldflags='-s -w' -o dist/esgo2dump_${{ github.ref_name }}_darwin_arm64 .
- name: create releases - name: create releases
id: create_release id: create_releases
uses: "marvinpinto/action-automatic-releases@latest" uses: "marvinpinto/action-automatic-releases@latest"
with: with:
repo_token: "${{ secrets.GITHUB_TOKEN }}" repo_token: "${{ secrets.GITHUB_TOKEN }}"
@ -43,6 +49,7 @@ jobs:
dist/esgo2dump_${{ github.ref_name }}_linux_amd64 dist/esgo2dump_${{ github.ref_name }}_linux_amd64
dist/esgo2dump_${{ github.ref_name }}_linux_arm64 dist/esgo2dump_${{ github.ref_name }}_linux_arm64
dist/esgo2dump_${{ github.ref_name }}_windows_amd64.exe dist/esgo2dump_${{ github.ref_name }}_windows_amd64.exe
dist/esgo2dump_${{ github.ref_name }}_windows_arm64.exe
dist/esgo2dump_${{ github.ref_name }}_darwin_amd64 dist/esgo2dump_${{ github.ref_name }}_darwin_amd64
dist/esgo2dump_${{ github.ref_name }}_darwin_amd64 dist/esgo2dump_${{ github.ref_name }}_darwin_amd64
dist/esgo2dump_${{ github.ref_name }}_darwin_arm64 dist/esgo2dump_${{ github.ref_name }}_darwin_arm64

3
.gitignore vendored
View File

@ -5,4 +5,5 @@ data.json
mapping.json mapping.json
setting.json setting.json
output.json output.json
*.txt *.txt
dist

View File

@ -13,6 +13,7 @@ import (
"github.com/elastic/go-elasticsearch/v7/esapi" "github.com/elastic/go-elasticsearch/v7/esapi"
"github.com/elastic/go-elasticsearch/v7/esutil" "github.com/elastic/go-elasticsearch/v7/esutil"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"net"
"net/http" "net/http"
"net/url" "net/url"
"strings" "strings"
@ -55,6 +56,7 @@ func NewClient(url *url.URL, iot interfaces.IO, qm map[string]any) (interfaces.D
RetryBackoff: nil, RetryBackoff: nil,
Transport: &http.Transport{ Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
DialContext: (&net.Dialer{Timeout: 5 * time.Second}).DialContext,
}, },
}, },
); err != nil { ); err != nil {

View File

@ -15,24 +15,28 @@
- download pre-build release: - download pre-build release:
[release](https://github.com/loveuer/esgo2dump/releases) [releases](https://github.com/loveuer/esgo2dump/releases)
### usage ### usage
`esgo2dump -h` `esgo2dump -h`
```bash
esgo2dump --input=http://127.0.0.1:9200/some_index --output=./data.json
esgo2dump --input=http://127.0.0.1:9200/some_index --output=http://192.168.1.1:9200/some_index --limit=5000
esgo2dump --input=https://username:password@127.0.0.1:9200/some_index --output=./data.json
esgo2dump --input=http://127.0.0.1:9200/some_index --output=./data.json --query='{"match": {"name": "some_name"}}'`,
```
### roadmap ### roadmap
[*] data dump - [x] data dump
- [x] mapping dump
[*] mapping dump - [x] es to file
- [x] es to es
[*] es to file - [x] auto create index with mapping
- [ ] auto create index with mapping,setting
[*] es to es - [ ] support es8
[*] auto create index with mapping
[ ] auto create index with mapping,setting
[ ] support es8