-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolves #108
- Loading branch information
Showing
6 changed files
with
154 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package configure | ||
|
||
import ( | ||
"github.com/algorandfoundation/nodekit/cmd/utils" | ||
"github.com/algorandfoundation/nodekit/cmd/utils/explanations" | ||
"github.com/algorandfoundation/nodekit/internal/algod" | ||
"github.com/algorandfoundation/nodekit/internal/system" | ||
"github.com/algorandfoundation/nodekit/ui/style" | ||
"github.com/charmbracelet/lipgloss" | ||
"github.com/charmbracelet/log" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var dataDir = "" | ||
var telemetryEndpoint string | ||
var telemetryName string | ||
|
||
var telemetryShort = "Configure telemetry for the Algorand daemon" | ||
var NodelyTelemetryWarning = "The default telemetry provider is Nodely." | ||
var telemetryLong = lipgloss.JoinVertical( | ||
lipgloss.Left, | ||
style.Purple(style.BANNER), | ||
"", | ||
style.Bold(telemetryShort), | ||
"", | ||
style.BoldUnderline("Overview:"), | ||
"When a node is run using the algod command, before the script starts the server,", | ||
"it configures its telemetry based on the appropriate logging.config file.", | ||
"When a node’s telemetry is enabled, a telemetry state is added to the node’s logger", | ||
"reflecting the fields contained within the appropriate config file", | ||
"", | ||
style.Yellow.Render(NodelyTelemetryWarning), | ||
) | ||
|
||
var telemetryCmd = utils.WithAlgodFlags(&cobra.Command{ | ||
Use: "telemetry", | ||
Short: telemetryShort, | ||
Long: telemetryLong, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
log.Warn(style.Yellow.Render(explanations.SudoWarningMsg)) | ||
sudoExists := system.CmdExists("sudo") | ||
if !sudoExists { | ||
log.Fatal("sudo is not installed, ensure it is available on your system in the PATH.") | ||
} | ||
diagExists := system.CmdExists("diagcfg") | ||
if !diagExists { | ||
log.Fatal("diagcfg is not installed, ensure it is available on your system in the PATH.") | ||
} | ||
|
||
dataDir, err := algod.GetDataDir(dataDir) | ||
|
||
err = system.RunAll(system.CmdsList{ | ||
{"sudo", "diagcfg", "-d", dataDir, "telemetry", "endpoint", "-e", telemetryEndpoint}, | ||
{"sudo", "diagcfg", "-d", dataDir, "telemetry", "name", "-n", telemetryName}, | ||
{"sudo", "diagcfg", "-d", dataDir, "telemetry", "enable"}, | ||
}) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
log.Debug("Restarting node...") | ||
err = algod.Stop() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
err = algod.Start() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
log.Debug("Node restarted successfully.") | ||
}, | ||
}, &dataDir) | ||
|
||
func init() { | ||
telemetryCmd.Flags().StringVarP(&telemetryEndpoint, "endpoint", "e", "https://tel.4160.nodely.io", "Sets the \"URI\" property") | ||
telemetryCmd.Flags().StringVarP(&telemetryName, "name", "n", "anon", "Enable Algorand remote logging with specified node name") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
docs/src/content/docs/reference/nodekit_configure_telemetry.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
title: "nodekit configure telemetry" | ||
slug: "reference/nodekit/configure/telemetry" | ||
--- | ||
## Synopsis | ||
Configure telemetry for the Algorand daemon | ||
|
||
Overview: | ||
When a node is run using the algod command, before the script starts the server, | ||
it configures its telemetry based on the appropriate logging.config file. | ||
When a node’s telemetry is enabled, a telemetry state is added to the node’s logger | ||
reflecting the fields contained within the appropriate config file | ||
|
||
The default telemetry provider is Nodely. | ||
|
||
``` | ||
nodekit configure telemetry [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-d, --datadir string Data directory for the node | ||
-e, --endpoint string Sets the "URI" property (default "https://tel.4160.nodely.io") | ||
-h, --help help for telemetry | ||
-n, --name string Enable Algorand remote logging with specified node name (default "anon") | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [nodekit configure](/reference/nodekit/configure) - Change settings on the system (WIP) | ||
|
||
###### Auto generated by spf13/cobra on 16-Jan-2025 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
## nodekit configure telemetry | ||
|
||
Configure telemetry for the Algorand daemon | ||
|
||
### Synopsis | ||
|
||
<img alt="Terminal Render" src="/assets/nodekit.png" width="65%"> | ||
Configure telemetry for the Algorand daemon | ||
|
||
Overview: | ||
When a node is run using the algod command, before the script starts the server, | ||
it configures its telemetry based on the appropriate logging.config file. | ||
When a node’s telemetry is enabled, a telemetry state is added to the node’s logger | ||
reflecting the fields contained within the appropriate config file | ||
|
||
The default telemetry provider is Nodely. | ||
|
||
``` | ||
nodekit configure telemetry [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-d, --datadir string Data directory for the node | ||
-e, --endpoint string Sets the "URI" property (default "https://tel.4160.nodely.io") | ||
-h, --help help for telemetry | ||
-n, --name string Enable Algorand remote logging with specified node name (default "anon") | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [nodekit configure](/man/nodekit_configure.md) - Change settings on the system (WIP) | ||
|
||
###### Auto generated by spf13/cobra on 16-Jan-2025 |