so iwanna to see the full of what happenned in the log what’s happening by turning off my quiet into false
this is my config before i try the log:
[agent]
interval = "20s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "5s"
flush_interval = "10s"
flush_jitter = "5s"
precision = "1ms"
debug = true
quiet = false
logtarget = "file"
logfile = "telegraflog"
logfile_rotation_interval = "1d"
logfile_rotation_max_size = "0"
logfile_rotation_max_archives = -1
log_with_timezone = "Asia/Jakarta"
hostname = ""
omit_hostname = false
[[outputs.influxdb_v2]]
urls = ["https://us-east-1-1.aws.cloud2.influxdata.com"]
token = "$env:INFLUX_TOKEN" #i need to set it that way to gain access to my telegraf log went the thing is running
organization = "63aee332ce56a036"
bucket = "MQTT input"
exclude_bucket_tag = true
timeout = "600s"
#user_agent = "telegraf"
[[inputs.mqtt_consumer]]
servers = ["mqtt://192.168.1.4:1883"]
topics = ["sensor/lokasi/kedalaman/#"]
qos = 1
connection_timeout = "600s"
max_undelivered_messages = 1000
persistent_session = true
## If unset, a random client ID will be generated.
client_id = "telegraf_cf820687"
username = "Rahman"
password = "sin356" # assuming typo here
data_format = "value"
influx_parser_type = "internal"
#influx_timestamp_precision = "1 millisecond"
[[inputs.mqtt_consumer.topic_parsing]]
topic = "sensor/lokasi/kedalaman/#"
measurement = "Hasil_Data"
tags = "_/lokasi/_/_"
fields = "sensor/lokasi/kedalaman/#"
[inputs.mqtt_consumer.topic_parsing.types]
data_type = "float"
the error is actually still the same the 401 unauthorized but maybe if you see the log it can help in where i was wrong on that config
I! Starting Telegraf 1.30.2 brought to you by InfluxData the makers of InfluxDB
I! Available plugins: 233 inputs, 9 aggregators, 31 processors, 24 parsers, 60 outputs, 5 secret-stores
I! Loaded inputs: mqtt_consumer
I! Loaded aggregators:
I! Loaded processors:
I! Loaded secretstores:
I! Loaded outputs: influxdb_v2
I! Tags enabled: host=<Host_Name>
I! [agent] Config: Interval:20s, Quiet:false, Hostname:<Host_Name>, Flush Interval:10s
D! [agent] Initializing plugins
D! [agent] Connecting outputs
D! [agent] Attempting connection to [outputs.influxdb_v2]
D! [agent] Successfully connected to outputs.influxdb_v2
D! [agent] Starting service inputs
I! [inputs.mqtt_consumer] Connected [mqtt://192.168.1.4:1883]
D! [inputs.mqtt_consumer] Session found [mqtt://192.168.1.4:1883]
D! [outputs.influxdb_v2] Buffer fullness: 0 / 10000 metrics
D! [outputs.influxdb_v2] Buffer fullness: 0 / 10000 metrics
D! [outputs.influxdb_v2] Buffer fullness: 0 / 10000 metrics
E! [outputs.influxdb_v2] When writing to [https://us-east-1-1.aws.cloud2.influxdata.com]: failed to write metric to MQTT input (401 Unauthorized): unauthorized: unauthorized access
[outputs.influxdb_v2] Buffer fullness: 1 / 10000 metrics
E! [agent] Error writing to outputs.influxdb_v2: failed to send metrics to any configured server(s)
[outputs.influxdb_v2] Buffer fullness: 1 / 10000 metrics
this is went im sent my payload as a test
D! [agent] Successfully connected to outputs.influxdb_v2
it said here in my log before i sent anything that my telegraf successfully connected to my influxdb but after that why error 401 occurs said its an unauthorized access. that is the part that confuse me
[1] token = “$env:INFLUX_TOKEN” is the same as
[2] token = “Ib2r5KcrNSG2El_XSPGqhQr6niKp_aSMn0wBT3h8PuWyCIBpDyOMhhSB8KB1NWILgHgBbDpF9HjCM-27O8EEVg==”
if i use the [1] the error will be transmitted into my telegraf log
if i use the [2] the error will be transmitted into my shells wihout further information
an also i want to ask this, is this server appropriate for influxDB cloud:
because i went and check the documentation for mqtt_consumer Input plug in and see the example for the server which is like this
## Broker URLs for the MQTT server or cluster. To connect to multiple
## clusters or standalone servers, use a separate plugin instance.
## example: servers = ["tcp://localhost:1883"]
## servers = ["ssl://localhost:1883"]
## servers = ["ws://localhost:1883"]
servers = ["tcp://127.0.0.1:1883"]
is this the reason?