-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Create processor that adds host IP addresses as tags #3756
Comments
It might be better to set a global tag with the information you would need to find the instance, you could potentially use an environment variable to set the value. The reason I suggest this is that this would tag all metrics with the information, and you wouldn't need to perform a separate lookup step. Also, InfluxDB does not excel at storing relation data or lists of values, so it would be difficult to come up with a good schema for storing the data separately, since as you know an interface can have many ip addresses. |
I solved this issue temporarily with global tag. but I still thought we need to consider the issue which hostname may be not the best option. From the standpoint of maintainers, need to know |
I might be misunderstanding, but what about just adding multiple global_tags? [global_tags]
ip1 = "192.168.0.1"
ip2 = "192.168.0.2"
ip3 = "192.168.0.3" If we wanted to automate adding this, I believe the way to go about it would be to have a processor plugin that can add these tags automatically. |
IP address will be changed, so we need a processor plugin that can add ip address as tag automatically. |
One question I still have is how should we decide which addresses to add in the processor? Would it make sense to create tags for all non-local addresses? Or perhaps have the user provide a list of networks to select:
Maybe we should use a dns lookup instead? This does introduce a network operation, normally not allowed by the processor interface, but should be fast and can be cached periodically so maybe it would be okay. In the future I think we need a "heavyweight" processor type for this type of operation. Another item to be considered is how will we name the tags if there are multiple addresses. The most query friendly is to duplicate the metric:
This allows you to select the data with any address, but is not very storage friendly. If we set the addresses like so then it will be hard to query because you must know which tag it is stored in:
|
Hi guys, can we have a new I wrote a piece of incomplete code about interface ip obtain: package main
import (
"fmt"
"net"
"strings"
)
func main() {
//----------------------
// Get the local machine IP address
// https://www.socketloop.com/tutorials/golang-how-do-I-get-the-local-ip-non-loopback-address
//----------------------
var currentIP, currentNetworkHardwareName string
// get all the system's or local machine's network interfaces
interfaces, _ := net.Interfaces()
for _, interf := range interfaces {
if addrs, err := interf.Addrs(); err == nil {
for _, addr := range addrs {
// check the address type and if it is not a loopback the display it
// = GET LOCAL IP ADDRESS
if ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
if ipnet.IP.To4() != nil {
currentIP = ipnet.IP.String()
// only interested in the name with current IP address`
if strings.Contains(addr.String(), currentIP) {
currentNetworkHardwareName = interf.Name
}
macAddress := interf.HardwareAddr
hwAddr, err := net.ParseMAC(macAddress.String())
if err != nil {
continue
}
currentNetworkHardwareName = strings.Replace(currentNetworkHardwareName, " ", "", -1)
fmt.Printf("interface,name=%s,ip_address=%s,mac_address=%s status=1\n",
currentNetworkHardwareName, currentIP, hwAddr)
}
}
}
}
}
} Compile it:
and it can be configured in
The output like:
|
Closing this since there is a workaround to use aixeshunter's code with the exec plugin. Thanks! |
Feature Request
telegraf is lack of an input plugin which can get all ip address of interfaces.
Proposal:
new an input plugin which can get all ip address of interfaces.
Current behavior:
no plugin which can get all ip address of interfaces.
Use case: [Why is this important (helps with prioritizing requests)]
I used telegraf +Influxdb+ grafana to monitor all instances in an openstack , but I found telegraf use hostname as index of measurements, not ip address. Now an issue is that I can't find the instance though I know the broken instance's hostname when monitoring on grafana web, because hostname of instance is permitted to modify by customer or tenant. I want an plugin which can get all ip addresses of interfaces in in instance.
The text was updated successfully, but these errors were encountered: