Skip to content

Commit

Permalink
SE-72: Rename pmm-transferer to pmm-dump
Browse files Browse the repository at this point in the history
  • Loading branch information
pooknull committed Mar 18, 2022
1 parent 301a403 commit 9cebba3
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 51 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
run: make build

- name: Test
run: ./pmm-transferer version
run: ./pmm-dump version

- name: Create Release
id: create_release
Expand All @@ -39,6 +39,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: pmm-transferer
asset_name: pmm-transferer
asset_path: pmm-dump
asset_name: pmm-dump
asset_content_type: application/x-executable
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.idea

main
pmm-transferer
/pmm-dump

setup/pmm/
setup/mongo/db/
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY= build up down re pmm-status mongo-reg mongo-insert export-all import-all clean

PMMT_BIN_NAME?=pmm-transferer
PMMD_BIN_NAME?=pmm-dump
PMM_DUMP_PATTERN?=pmm-dump-*.tar.gz

PMM_URL?="http://admin:admin@localhost:8282"
Expand All @@ -22,7 +22,7 @@ COMMIT:=$(shell git rev-parse --short HEAD)
all: build re mongo-reg mongo-insert export-all re import-all

build:
go build -ldflags "-X 'main.GitBranch=$(BRANCH)' -X 'main.GitCommit=$(COMMIT)'" -o $(PMMT_BIN_NAME) pmm-transferer/cmd/transferer
go build -ldflags "-X 'main.GitBranch=$(BRANCH)' -X 'main.GitCommit=$(COMMIT)'" -o $(PMMD_BIN_NAME) pmm-dump/cmd/pmm-dump

up:
mkdir -p setup/pmm && touch setup/pmm/agent.yaml && chmod 0666 setup/pmm/agent.yaml
Expand All @@ -48,20 +48,20 @@ mongo-insert:
--eval 'db.getSiblingDB("mydb").mycollection.insert( [{ "a": 1 }, { "b": 2 }] )' admin

export-all:
./$(PMMT_BIN_NAME) export -v --dump-path $(DUMP_FILENAME) \
./$(PMMD_BIN_NAME) export -v --dump-path $(DUMP_FILENAME) \
--pmm-url=$(PMM_URL) --dump-core --dump-qan

export-vm:
./$(PMMT_BIN_NAME) export -v --dump-path $(DUMP_FILENAME) \
./$(PMMD_BIN_NAME) export -v --dump-path $(DUMP_FILENAME) \
--pmm-url=$(PMM_URL) --dump-core

export-ch:
./$(PMMT_BIN_NAME) export -v --dump-path $(DUMP_FILENAME) \
./$(PMMD_BIN_NAME) export -v --dump-path $(DUMP_FILENAME) \
--pmm-url=$(PMM_URL) --dump-qan

import-all:
./$(PMMT_BIN_NAME) import -v --dump-path $(DUMP_FILENAME) \
./$(PMMD_BIN_NAME) import -v --dump-path $(DUMP_FILENAME) \
--pmm-url=$(PMM_URL) --dump-core --dump-qan

clean:
rm -f $(PMMT_BIN_NAME) $(PMM_DUMP_PATTERN) $(DUMP_FILENAME)
rm -f $(PMMD_BIN_NAME) $(PMM_DUMP_PATTERN) $(DUMP_FILENAME)
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PMM Transferer (pmm-import-export-tool)
# PMM Dump (pmm-import-export-tool)

A tool that will fetch data from PMM and import it into local instance. Will help Percona Services engineers to resolve issues when the customer cannot provide access to their PMM instance.

Expand All @@ -8,14 +8,14 @@ You will need to have Go 1.16+ installed.

In the root directory: `make build`

## Using Transferer
## Using PMM Dump

The transfer process is split into two main parts: export and import.

In order to run either export or import, you have to specify PMM URL at least:
```
./pmm-transferer export --pmm-url "http://USER:PASS@HOST"
./pmm-transferer import --pmm-url "http://USER:PASS@HOST" --dump-path FILENAME.tar.gz
./pmm-dump export --pmm-url "http://USER:PASS@HOST"
./pmm-dump import --pmm-url "http://USER:PASS@HOST" --dump-path FILENAME.tar.gz
```

Here are main commands/flags:
Expand Down Expand Up @@ -62,16 +62,16 @@ The same for `where` QAN filter: `service_name='mongo'` or `service_id='/service
Also, you can use `instance` option which filters QAN and core metrics by service name

```
> ./pmm-transferer export --pmm-url="http://admin:admin@localhost:8282" --ts-selector=`{service_name="mongo"}` --dump-qan --where=`service_name='mongo'`
> ./pmm-dump export --pmm-url="http://admin:admin@localhost:8282" --ts-selector=`{service_name="mongo"}` --dump-qan --where=`service_name='mongo'`
```
is same as
```
> ./pmm-transferer export --pmm-url="http://admin:admin@localhost:8282" --instance="mongo" --dump-qan
> ./pmm-dump export --pmm-url="http://admin:admin@localhost:8282" --instance="mongo" --dump-qan
```

To filter by multiple dashboards, you can use `dashboard` flag multiple times:
```
> ./pmm-transferer export --pmm-url="http://admin:admin@localhost:8282" --dashboard='MongoDB Instances Overview' --dashboard='MySQL Instances Overview'`
> ./pmm-dump export --pmm-url="http://admin:admin@localhost:8282" --dashboard='MongoDB Instances Overview' --dashboard='MySQL Instances Overview'`
```

In some cases you would need to override default configuration for VM/CH processing:
Expand All @@ -84,9 +84,9 @@ In some cases you would need to override default configuration for VM/CH process
| export | chunk-rows | Amount of rows to fit into a single chunk (CH only) | `1000` |

### Using in pipelines
You can redirect output to STDOUT with --stdout option. It's useful to redirect output to another pmm-transferer in a pipeline:
You can redirect output to STDOUT with --stdout option. It's useful to redirect output to another pmm-dump in a pipeline:
```
> ./pmm-transferer export --pmm-url="http://admin:admin@localhost:8282" --dump-qan --stdout | ./pmm-transferer import --pmm-url="http://admin:admin@localhost:8282" --dump-qan
> ./pmm-dump export --pmm-url="http://admin:admin@localhost:8282" --dump-qan --stdout | ./pmm-dump import --pmm-url="http://admin:admin@localhost:8282" --dump-qan
```

## About the dump file
Expand All @@ -104,15 +104,15 @@ There is a Makefile for easier testing locally. It uses docker-compose to set up

You will need to have Go 1.16+ and Docker installed.

| Rule | Description |
|------|-------------|
| make | Shortcut for fast test |
| make build | Builds transferer binary |
| make up | Sets up docker containers |
| mongo-reg | Registers MongoDB in PMM |
| mongo-insert | Executes MongoDB insert |
| Rule | Description |
|------|------------------------------|
| make | Shortcut for fast test |
| make build | Builds pmm-dump binary |
| make up | Sets up docker containers |
| mongo-reg | Registers MongoDB in PMM |
| mongo-insert | Executes MongoDB insert |
| make down | Shuts down docker containers |
| make re | Shortcut for `down up` |
| make export-all | Runs export from local PMM |
| make re | Shortcut for `down up` |
| make export-all | Runs export from local PMM |

For more rules, please see `Makefile`
File renamed without changes.
16 changes: 8 additions & 8 deletions cmd/transferer/main.go → cmd/pmm-dump/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"fmt"
"github.com/valyala/fasthttp"
"os"
"pmm-transferer/pkg/clickhouse"
"pmm-transferer/pkg/dump"
"pmm-transferer/pkg/grafana"
"pmm-transferer/pkg/transferer"
"pmm-transferer/pkg/victoriametrics"
"pmm-dump/pkg/clickhouse"
"pmm-dump/pkg/dump"
"pmm-dump/pkg/grafana"
"pmm-dump/pkg/transferer"
"pmm-dump/pkg/victoriametrics"
"time"

"github.com/alecthomas/kingpin"
Expand All @@ -25,7 +25,7 @@ var (

func main() {
var (
cli = kingpin.New("pmm-transferer", "Percona PMM Transferer")
cli = kingpin.New("pmm-dump", "Percona PMM Dump")

// general options
pmmURL = cli.Flag("pmm-url", "PMM connection string").String()
Expand Down Expand Up @@ -187,7 +187,7 @@ func main() {

t, err := transferer.New(*dumpPath, *stdout, sources, *workersCount)
if err != nil {
log.Fatal().Msgf("Failed to transfer: %v", err)
log.Fatal().Msgf("Failed to setup export: %v", err)
}

var chunks []dump.ChunkMeta
Expand Down Expand Up @@ -264,7 +264,7 @@ func main() {

t, err := transferer.New(*dumpPath, piped, sources, *workersCount)
if err != nil {
log.Fatal().Msgf("Failed to transfer: %v", err)
log.Fatal().Msgf("Failed to setup import: %v", err)
}

meta, err := composeMeta(*pmmURL, httpC)
Expand Down
4 changes: 2 additions & 2 deletions cmd/transferer/util.go → cmd/pmm-dump/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"github.com/pkg/errors"
"os"
"pmm-transferer/pkg/dump"
"pmm-dump/pkg/dump"
"runtime"
"strconv"
"strings"
Expand Down Expand Up @@ -84,7 +84,7 @@ func composeMeta(pmmURL string, c *fasthttp.Client) (*dump.Meta, error) {
}

meta := &dump.Meta{
Version: dump.TransfererVersion{
Version: dump.PMMDumpVersion{
GitBranch: GitBranch,
GitCommit: GitCommit,
},
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module pmm-transferer
module pmm-dump

go 1.16

Expand Down
4 changes: 2 additions & 2 deletions pkg/clickhouse/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
"io"
"pmm-transferer/pkg/clickhouse/tsv"
"pmm-transferer/pkg/dump"
"pmm-dump/pkg/clickhouse/tsv"
"pmm-dump/pkg/dump"
"strings"
"time"
)
Expand Down
8 changes: 4 additions & 4 deletions pkg/dump/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const (
)

type Meta struct {
Version TransfererVersion `json:"version"`
PMMServerVersion string `json:"pmm-server-version"`
MaxChunkSize int64 `json:"max_chunk_size"`
Version PMMDumpVersion `json:"version"`
PMMServerVersion string `json:"pmm-server-version"`
MaxChunkSize int64 `json:"max_chunk_size"`
}

type TransfererVersion struct {
type PMMDumpVersion struct {
GitBranch string `json:"git-branch"`
GitCommit string `json:"git-commit"`
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/transferer/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"io/ioutil"
"os"
"path"
"pmm-transferer/pkg/dump"
"pmm-dump/pkg/dump"
)

func ReadMetaFromDump(dumpPath string, piped bool) (*dump.Meta, error) {
Expand Down Expand Up @@ -119,7 +119,7 @@ func readAndCompareDumpMeta(r io.Reader, runtimeMeta dump.Meta) {
}

if dumpMeta.Version.GitCommit != runtimeMeta.Version.GitCommit {
log.Warn().Msgf("Transferer version mismatch\nExported:\t%v\nCurrent:\t%v",
log.Warn().Msgf("pmm-dump version mismatch\nExported:\t%v\nCurrent:\t%v",
dumpMeta.Version.GitCommit, runtimeMeta.Version.GitCommit)
}
}
4 changes: 2 additions & 2 deletions pkg/transferer/transferer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"io"
"os"
"path"
"pmm-transferer/pkg/dump"
"pmm-dump/pkg/dump"
"runtime"
"sync"
"time"
Expand All @@ -26,7 +26,7 @@ type Transferer struct {

func New(dumpPath string, piped bool, s []dump.Source, workersCount int) (*Transferer, error) {
if len(s) == 0 {
return nil, errors.New("failed to create transferer with no sources")
return nil, errors.New("no sources provided")
}

if workersCount <= 0 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/victoriametrics/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"io"
"io/ioutil"
"pmm-transferer/pkg/dump"
"pmm-dump/pkg/dump"
"strconv"
"time"

Expand Down

0 comments on commit 9cebba3

Please sign in to comment.